Syntax to increment variable names in repeat loop
Keith Clarke
keith.clarke at clarkeandclarke.co.uk
Tue May 24 06:03:48 EDT 2011
Yes, an array seems to be the way to go, as LiveCode doesn't throw errors (yet!) if I use...
repeat with tCycle = 1 to 10
put "some ugly returned XML string" into tResult[tCycle]["Response"]
end repeat
Thanks for listening! :-)
Best,
Keith..
On 24 May 2011, at 10:48, Keith Clarke wrote:
> Thanks for responding John but in my scenario, I can't use 'after' in a single variable. Each loop cycle is calling a web service and returning an XML string that I need to place in a unique variable, related to the loop cycle, for subsequent aggregation.
> Thinking about it, maybe I could put all the XML strings into a single variable in array form. I'll experiment with that.
> Best,
> Keith..
>
> On 24 May 2011, at 10:27, John Dixon wrote:
>
>>
>>
>> Not too sure I fully understand... but is something like this what you are after ?
>>
>> on mouseUp
>> put "jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec" into monthList
>>
>> repeat with count = 1 to 12
>> put (item count of monthList & count) & cr after theList
>> end repeat
>>
>> put theList
>> end mouseUp
>>
>> Be well
>>
>>> Hi folks,
>>> I have a repeat loop with tCycle = 1 to 10 and for each repeat, I need to put something into a new variable, specific to the particular cycle - tResultCycle1, tResultCycle2... tResultCycle10.
>>>
>>> How does one script the creation of a unique variable for each loop, as LiveCode doesn't seem to like the attempted simple variable name concatenation in...
>>>
>>> put "something" into tResult & tCycle
>>>
>>> I'm guessing I need to define the variable's name before using it, but 'variableNames' doesn't seem to fit the bill and as the dictionary doesn't even have an entry for 'variable' (so they're obviously not important!), I'm struggling to find any seed terms to search the list archives.
>>>
>>> Then again, maybe I'm missing something fundamental here - my default state with LiveCode, it seems! :-)
>>> Best,
>>> Keith..
>>
>
More information about the use-livecode
mailing list