top of page

16

Beginner

AZ_tableSameFileNum

配列の中の指定のファイルの格納位置を取得

RANK

dofile(reaper.AZ_GetLuaInitPath())


function tableSameFileNum(table,file)

     local t = table

     local f = file

     local c = 1

    for x, value in pairs(t) do

          if t[x] == f then

             c = x

            goto e

          else

             c = nil

         end

    end

::e::

return c

end


t = {10,20,30,40,50}

a = tableSameFileNum(t,30)

Msg(a)

dofile(reaper.AZ_GetLuaInitPath())


function tableSameFileNum(table,file)


  • 配列内の文字列が格納されている位置を取得する関数を定義する。


local t = table

local f = file

local c = 1


  • 引数を変数に格納し、戻り値用の変数(c)をデフォルト1で初期化する。


for x, value in pairs(t) do

if t[x] == f then

c = x

goto e

else

c = nil

end

end

::e::

return c


  • 配列の要素数だけ処理を繰り返し、配列に格納されている値が変数(f)と一致すればその位置、しなければnilを変数(c)の値とする。

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

専用APIをダウンロード

する必要があります。

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

準備の必要はありません

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

LUA

​ReaScript File Download 👇

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

- Script Download -
bottom of page