Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
field "TagA",FIN
field "TagB", TRN
field "TagC",BCN
I wish to loop through the list setting the values into the fields. Is it possible to use the first item directly in code to refer to a field control where the first item is 'field "TagA". I have tried the following but it does not work (it writes data back to the list)
on mouseUp
Repeat for each line tline in tPrefsData
put item 1 of tLine into tFld
put item 2 of tLine into tData
do "put" && tdata && "into" && tFld
end Repeat
end mouseUp
This is a bit wordy, but intentionally so for clarity. The issue is old; LC needs an extra level of evaluation to make sense of your original statement. That thinking was really OK, but just one level removed of what LC can parse and compile correctly. Please play with this. It is an invaluable part of your LC arsenal.
I have not tried your second example but will give it a try. I am not sure that it will work: Item 1 of tLine is set to : Field "Tag1" so unless the engine can resolve fld(Field "Tag1") it is sure to throw an error.
I have written a second handler that strips the text after the word field so it gives Tag1 in the example above. I have compared the two methods of writing the data to the fields calling the routines a 1000 times. Using the Do command took 435ms whereas using the loop that extracts the name took 287ms. Also using the Do command requires protective code against blanks and text that it thinks is a command. So the Do is useful but needs care.