top of page
- API -

dofile(reaper.AZ_GetLuaInitPath())


function textTableChanger(table,str,Number,Count)

local a = table local a = {} local b = Count local c = Number local d = 0 local e = 0

for word in str:gmatch("([^,]*)") do

c = c +1

if b > 1 then

if d == 0 then e = e+1 a[e] = {}end

d = d +1

a[e][d] = word

if d == Count then d = 0 end

else

a[c] = word

end

end

return a

end


text = "1,2,3,4,5,6,7,8"

c = {}

c = textTableChanger(c,text,0,1)

Msg(c[3])


c = {}

c = textTableChanger(c,text,0,2)

Msg(c[4][2])


c = {}

c = textTableChanger(c,text,0,3)

Msg(c[3][1])

- API Detail-

No preparation required

- SCRIPT -

dofile(reaper.AZ_GetLuaInitPath())


  • Loading the initial settings for the Lua version of RIGDOCKS


function textTableChanger(table,str,Number,Count)


  • Define a function that stores a comma-separated string in an array.


local a = table local a = {} local b = Count local c = Number local d = 0 local e = 0


  • Store the arguments in variables and initialize the counting variable to 0.


for word in str:gmatch("([^,]*)") do

c = c +1


  • Split the argument (str) with commas, and repeat steps 5 to 6 below for each split string. Increment the variable (c) each time.


if b > 1 then

if d == 0 then e = e+1 a[e] = {}end

d = d +1

a[e][d] = word

if d == Count then d = 0 end


  • If variable (b) (the Count argument) is greater than 1, and if variable (d) is 0, add 1 to variable (e) and store an empty array in the (e)th position of the array.

  • Add 1 to variable (d) and store the string split by 4 in the (d)th position of the array stored in the (e)th position of the array.

  • When the variable (d) becomes equal to the argument (Count), (d) is initialized to 0.

- SCRIPT -

Beginner

AZ_textTableChanger

Split a comma-separated string

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