Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String variables in array possible?
#1
I have the following code:

Macro Macro4
Code:
Copy      Help
str c="created"
str a="accessed"
str m="modified"


ARRAY(str) arr_dates
arr_dates.create(3)
arr_dates[0]="c"
arr_dates[1]="a"
arr_dates[2]="m"


str string_dates


;Desired format for "string_dates", using the array "arr_dates"
;Does not have to look exactly this. Most important is, "string_dates" uses arr_dates"
;string_dates=F"{c};{a};{m}"

;desired "string_dates" output, exactly like this:
;,created;accessed;modified


string_dates is build using the array arr_dates (the array contains the variables)

The output of string_dates would be exactly like this:
Code:
Copy      Help
created;accessed;modified

It also needs to work in compiled exe, is this possible? (If it is possible, then what is written below can be skipped).

If it is not possible maybe I am approaching my problem in a wrong way:

There are 3 parameters "c" , "a" and "m" that are passed in a string "get_date" like this
Code:
Copy      Help
str get_date="c;a;m"

I use 'tok' to create an array that contains the split "get_date" string.
Code:
Copy      Help
nt3=tok(get_date arr_nt3 -1 ";")

The problem is, the arguments can be passed in different sequence order: "a;m;c" , "m;a;c" or less then 3 parameters "a;c" , "c" ...etc. I must keep the sequence in which the c,a,m -paramaters are passed.
That's why I use 'arr_nt3' , it contains the parameters in correct order.

"a", "c" and "m" are also string variables, to avoid confusion:
Code:
Copy      Help
arr_nt3[0]=c
...
str c="dates c"

I want to put "a","c","m" in "string_dates" which could look like this:

Code:
Copy      Help
string_dates=F"{c};{a}"
or
Code:
Copy      Help
string_dates=F"{m};{a};{c}"
etc...

How can I build "string_dates" based on the passed argument "c;a;m" (or "a;c" , "m;a;c", etc...)?
#2
Variable names in string - not possible.

Try this:
Macro Macro1271
Code:
Copy      Help
str c="created"
str a="accessed"
str m="modified"


ARRAY(str*) arr_dates
arr_dates.create(3)
arr_dates[0]=&c
arr_dates[1]=&a
arr_dates[2]=&m


str string_dates
string_dates=F"{*arr_dates[0]};{*arr_dates[1]};{*arr_dates[2]}"
out string_dates
#3
Macro Macro1968
Code:
Copy      Help
str get_date=
;c=created
;a=accessed
;m=modified
IStringMap m._create; m.AddList(get_date "=")

ARRAY(str) arr_dates="c[]a[]m"

str string_dates
string_dates=F"{m.Get(arr_dates[0])};{m.Get(arr_dates[1])};{m.Get(arr_dates[2])}"
out string_dates
#4
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)