Running and stepping thru a repeat loop not the same

J. Landman Gay jacque at hyperactivesw.com
Mon Feb 13 00:19:16 EST 2006


This looks like another case of something that just came up on the list 
-- altering the repeat variable inside the loop is a no-no and you get 
unexpected results. The repeat variable is read-only. During debugging, 
the IDE will apparently protect the result, but when run on its own, the 
variable will be unpredictable if you try to alter it.

Change your script to this:

set the itemdel to tab
repeat for each line tLine in tOld
     put tLine & tab & item 5 of tLine & item 4 of tLine & \
        item 2 of tLine & cr after oldResults
end repeat

This treats the repeat variable as read-only and should work.


Jim Hurley wrote:
> This  is weird beyond measure. When I step 5 times through the repeat 
> loop below I get the expected results--see below.
> 
> When I allow the loop to "run" the first few lines are the second set of 
> results below. They are completely different and incomprehensible.
> 
> The purpose is to add a new database field which is a combination of the 
> street name, street number, and last name of the voter.
> 
> set the itemdel to tab
> repeat for each line tLine in tOld
>     put tab & item 5 of tLine & item 4 of tLine & item 2 of tLine  after 
> tLine
>     put tLine & cr after oldResults
> end repeat
> 
> 
> First few lines of the variable oldResults obtained by stepping through 
> the loop. Exactly what I expected.
> 
> (Voter ID    LAST    FIRST    ST.NO.    STREET    PARTY    DATE    
> ComboField)
> 
> 30871    KOVACS    JUDITH    237    ADAMS    NP    02/19/2002    
> ADAMS237KOVACS
> 47200    SHARP    KATHERINE    237    ADAMS    DEM    09/11/1995 
>     ADAMS237SHARP
> 107995    NUCKELS    ANDREA    239    ADAMS    REP    08/07/2003    
> ADAMS239NUCKELS
> 48272    RUSSELL    ANNA    239    ADAMS    NP    09/01/2000    
> ADAMS239RUSSELL
> 778    BRITTEN    CONSTANCE    239    ADAMS    GRN    08/18/1999 
>     ADAMS239BRITTEN
> 
> (The results above would all line up nicely with the proper setting of 
> the tabs.)
> 
> First few lines of the variable oldResults obtained by running the loop. 
> Totally bizarre results.
> 
> 30871    KOVACS    JUDITH    237    ADAMS    NP    02/19/2002    
> ADAMS237KOVACS
> 30871    KOVACS    JUDITH    237    ADAMS    NP    02/19/2002    AD 
>     ADAMS237SHARP
> 107995    NUCKELS    ANDREA    239    ADAMS    REP    08/07/2003    
> ADAMS239NUCKELS
> 107995    NUCKELS    ANDREA    239    ADAMS    REP    08/07/    
> ADAMS239RUSSELL
> 107995    NUCKELS    ANDREA    239    ADAMS    REP    08/07/    ADA    
> ADAMS239BRITTEN
> 107995    NUCKELS    ANDREA    239    ADAMS    REP    08/07/    ADA    A 
>     ADAMS239NUCKELS
> 
> Jim
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 
> 


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list