top of page

13

Beginner

AZSTOKe_sample_textTableChanger

Split and get comma separated string

RANK

function Msg(param)

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

end


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])

function Msg(param)

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

end


  • Msg Set the console output function


function textTableChanger(table,str,Number,Count)


  • Define a function that stores comma-separated strings 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.

To use the API, you need to sign up for a plan.

Download the dedicated API

need to do it.

*SILVER is scheduled to be released in May.

No preparation required

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

LUA

​ReaScript File Download 👇

* A dedicated API is required to run this

- Script Image -
bottom of page