Page 1 of 1

repeat in variable

Posted: Tue Mar 31, 2015 10:02 pm
by vedus
In my stack i have bellow objects..
1 group with some fields and 2 variables.
Variable 1 have the field names and variable 2 have the values i want like (name1,name2,etc)
I want to get the field name from the var 1 and pass the value from var 2 into text of field.
is that possible and how to?
my code until now

Code: Select all

repeat with x=1 to the number of flds of group "grp-A"
          add 1 to counter
          put the short name of  fld x & cr after fNames
     end repeat

     set the itemdel to comma
     put 0 into myCounter
     repeat for each line f in fNames
          repeat for each line t in tvalues

          end repeat
     end repeat

Re: repeat in variable

Posted: Tue Mar 31, 2015 10:25 pm
by SparkOut
You have a lot of unnecessary lines to do this job

Code: Select all

repeat with x=1 to the number of flds of group "grp-A"
   put line x of tValues into field x of group "grp-A"
 end repeat
But if you want to refer to a field by resolving a variable name, you can put the name in parentheses:

put "data" into field (tFieldVar)

You might get away without the parentheses but don't leave them out. It makes things so much better for the engine.

Re: repeat in variable

Posted: Tue Mar 31, 2015 10:31 pm
by vedus
SparkOut wrote:You have a lot of unnecessary lines to do this job

Code: Select all

repeat with x=1 to the number of flds of group "grp-A"
   put line x of tValues into field x of group "grp-A"
 end repeat
But if you want to refer to a field by resolving a variable name, you can put the name in parentheses:

put "data" into field (tFieldVar)

You might get away without the parentheses but don't leave them out. It makes things so much better for the engine.
Thank you Sparkout,i will give a try.