top of page

1

File/Folder

AZSTOKE_TextFileWirteRead

セーブデータ構築Part1-テキストファイルを書き出しと読み込み-

RANK

os = reaper.GetOS()

if "Win" == string.match(os,"(Win)") then

     package.cpath = package.cpath .. ";"..reaper.GetResourcePath() .."/UserPlugins/?.dll"

else

    package.cpath = package.cpath .. ";"..reaper.GetResourcePath() .."/UserPlugins/?.dylib" 

end

require("reaper_AZSTOKE_SILVER")


function Msg(param)

   reaper.ShowConsoleMsg(tostring(param).."\n")

end


fileName = "saveDate.txt"


_,folderPath,addPath = reaper.AZ_SetResoucePathFolder("AZSTOKE",0)

retval,inputList = AZ_SILVER.AZ_GetUserInputList("Info",3,"Path:,Wav:,Count:","D:/,test,5")


if retval then 

   saveText = ""

   for i, value in pairs(inputList) do

       if i == 1 then

          saveText = value

       else

          saveText = saveText..","..value

       end

   end

   reaper.AZ_WriteFile(folderPath,fileName,saveText,0)

   retval,saveText = reaper.AZ_ReadFile(folderPath,fileName)

   _,splitList = AZ_SILVER.AZ_GetStringSplitList(saveText,",")

   for i, value in pairs(splitList) do

       Msg(splitList[i])

   end

end

package.cpath = package.cpath .. ";"..reaper.GetResourcePath() .."/UserPlugins/?.dll"

require("reaper_AZSTOKE_SILVER")


・SilverAPIを利用可能にする


function Msg(param)

   reaper.ShowConsoleMsg(tostring(param).."\n")

end


・デバック用コンソール出力関数を用意


fileName = "saveDate.txt"


・ファイル名を拡張子を入れて文字列「saveDate.txt」をfileNameに代入


_,folderPath,addPath = reaper.AZ_SetResoucePathFolder("AZSTOKE",0)


・リソースフォルダに"AZSTOKE"というフォルダを作成


retval,inputList = AZ_SILVER.AZ_GetUserInputList("Info",3,"Path:,Wav:,Count:","D:/,test,5")


・UserInputで3つのインプット情報を設定、実行後に入力したものをinputListに代入


if retval then 


・GetUserInputListをキャンセルしていない場合


   saveText = ""


・空のsaveTextを用意


   for i, value in pairs(inputList) do


・inputList分ループ再生


       if i == 1 then

          saveText = value


・最初はsaveTextにそのままvalueを代入


       else

          saveText = saveText..","..value


・2回目以降はsaveTextに区切りの","を入れてからvalueを語尾に追記して代入


       end

   end

   reaper.AZ_WriteFile(folderPath,fileName,saveText,0)


・指定フォルダパスにsaveTextを記載したファイルを生成


   retval,saveText = reaper.AZ_ReadFile(folderPath,fileName)


・さきほど生成したファイルを読み込みsaveTextに出力


   _,splitList = AZ_SILVER.AZ_GetStringSplitList(saveText,",")


・saveTextの区切りをもとに配列に変更


   for i, value in pairs(splitList) do


・splitListごとにループ再生


       Msg(splitList[i])


・splitListごとにコンソール出力、出力されているか確認


   end

end

APIの利用にはプランに加入し

専用APIをダウンロード

する必要があります。

​※SILVERは5月中の公開を予定しております

- Script Code -
- Script Image -
- Warm Up -
- Script Detail -
- API LINK -

LUA

​ReaScript File Download 👇

​※実行するには専用APIが必要です

- Script Download -
bottom of page