Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
names (of anything) as variables
#1
This is a problem I encountered many times:
In a repeat command, I want to refer to a different string or macro or anything alike, each cycle. I want the name of the string, for example, to be a variable.
It should be more or less something like this:

str strng1="one"
str strng2="two"
str strng3="three"
int i
i=0
rep
if(i=3) break
i=i+1
mes strngi (or strng+i, or anything)

the result should be 3 following messages: one, two, three
do you know any way to do something like this?
#2
Macro
Code:
Copy      Help
str ss="one[]two[]three"
str s
foreach s ss
,mes s

;or

str strng1="one"
str strng2="two"
str strng3="three"
str* a=&strng1 ;;note: other variables must not be declared between string1, string2 and string3
int i
for i 0 3
,mes a[i]

;or

ARRAY(str) sa.create(3)
sa[0]="one"
sa[1]="two"
sa[2]="three"
int j
for j 0 a.len
,mes sa[j]
#3
I applied the second solution you offered, and it works great!
thanks!!!
Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)