Posts: 151
Threads: 90
Joined: Aug 2014
07-20-2018, 10:37 AM
(This post was last modified: 07-20-2018, 10:38 AM by BK.)
Hello
I want to store the text of the variable S in the variables arr [i] and arr2 [i] separately.
But I don't know the command and how to do it.
Ask for help.
output
arr[i]=
221
51
11
arr2[i]=
41
122
10
Function
Function1
str s =
;221 41
;51 122
;11 10
ARRAY(str) arr arr2
int i nt
nt = tok(s arr 2 " " 4|8|16|0x2000 arr2)
for(i 0 nt)
,;out arr[i]
,out arr2[i]
Posts: 12,087
Threads: 142
Joined: Dec 2002
Macro
Macro6
out
str s =
;221 41
;51 122
;11 10
ARRAY(str) arr arr2 t
int i nt
nt=tok(s t -1 " []")
arr.create(nt/2)
arr2.create(nt/2)
for i 0 nt
,if(i&1) t[i].swap(arr2[i/2]); else t[i].swap(arr[i/2])
out "arr:"
out arr
out "arr2:"
out arr2
or
Macro
Macro7
out
str s =
;221, 41
;51, 122
;11, 10
ICsv x._create
x.FromString(s)
int i
out "arr:"
for(i 0 x.RowCount) out x.Cell(i 0)
out "arr2:"
for(i 0 x.RowCount) out x.Cell(i 1)
Posts: 117
Threads: 5
Joined: Nov 2015
Another method:
Macro
8
out
str s =
;221 41
;51 122
;11 10
ARRAY(str) a1 a2
str line
foreach line s
,sub.SplitString line a1 a2
out "Array1:"
out a1
out ""
out "Array2:"
out a2
#sub SplitString
function str&x ARRAY(str)&a1 ARRAY(str)&a2
ARRAY(str) a
int ntok=tok(x a)
a1[]=a[0]
a2[]=a[1]