top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath())


function table.maxn( table )

local maxn, k = 0, nil

repeat

k = next( table, k )

if type( k ) == 'number' and k > maxn then

maxn = k

end

until not k

return maxn

end


a = {"a","b","c"}

x = table.maxn(a)

Msg(x)

- Warm Up -

No preparation required

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())


  • Loading the initial settings for the Lua version of RIGDOCKS


function table.maxn( table )


  • Define a function to find the maximum value of an array


local maxn, k = 0, nil


  • Define a variable to store the maximum value and a variable to store the array values


repeat

k = next( table, k )

if type( k ) == 'number' and k > maxn then

maxn = k

end

until not k


  • Gets an index value from the array. If the obtained value can be converted to a number and is greater than the temporary maximum value, the obtained value becomes the temporary maximum value. This process is repeated from the beginning to the end of the array.


return maxn


  • The interim maximum is returned as the final maximum.


a = {"a","b","c"}

x = table.maxn(a)

- API LINK -

Beginner

AZ_tableMaxn

Print the length of an array

01_BRONZE_ss_edited.png
01_SILVER_edited_edited.png
03_GOLD_edited_edited.png
bottom of page