How can we dynamically create variable names from changing value "x" on a loop?

Ben Rubinstein benr_mc at cogapp.com
Mon Nov 7 12:46:08 EST 2016


On 07/11/2016 16:52, Richard Gaskin wrote:
> But more seriously, the meat here is this:
>
>>   doSomething item viUserID of tRec, item viUserName of tRec
>
> ...vs:
>
>>   doSomething aData["User ID"], aData["User Name"]
>
> On the one hand, each array access requires a small amount of overhead to run
> the key through a hash to find the value's address.  However, that overhead is
> pretty small...


No, no - the meat here is this:

>     do makeAccessVars("vi", line 1 of tTSVdata)
>     ...
>     repeat for each line tRec in tTSVdata


vs


>     repeat for each line tRec in tTSVdata
>         put explodeRow(tRec, tColumnNames) into aData


I wouldn't care to hazard a guess as to the relative speed of "aData[x]" 
versus "item x": but it's the overhead of the function which creates the array 
on that I don't want to pay *on every row*.

Ben




More information about the Use-livecode mailing list