Why?

Tariel Gogoberidze PMDA at earthlink.net
Thu Mar 6 16:53:01 EST 2003


 > Message: 3
 > Date: Thu, 6 Mar 2003 12:42:47 +0100
 > Subject: Re: Why?
 > From: Klaus Major <k_major at os.surf2000.de>
 >
 > Hi Tariel,
 >
 >>on mouseUp
 >>
 >>  Put "N,33,0,No Answer" into line 1 of TestLog
 >>  Put "N,11,0" into line 2 of TestLog
 >>
 >>  repeat for each line LL in TestLog
 >>    if last char of LL <> comma then
 >>      put comma after LL
 >>      -- HERE LL with line 2 of TestLog gets replaced
 >>      -- by previous LL which was holding line 1 of TestLog
 >>    end if
 >>    add item 2 of LL to tTest
 >>  end repeat
 >>
 >>  put tTest
 >>
 >>  -- returns 66 instead of 44 that one might expect
 >>
 >>end mouseUp
 >>
 >>I was getting inconsistent results in large script and it took me a
 >>while to narrow down the bug to the script above.
 >>I can work around this phenomena of course but just curious why is
 >>this happening?
 >>
 >>Best regards
 >>Tariel
 >
 >
 > This is no bug but "repeat for each xxx" is a READ-only thing.
 > That means you cannot change "each xxx", just read it.
 > So you will have to put a "modified "each xxx" into another variable.


 >Regards

 > Klaus Major
 > k_major at os.surf2000.de

Thanks for reply Klaus, but I guess it's more complicated than "repeat 
for each xxx" is a READ-only thing". Well, at least it's inconsistent. 
Sometimes it behaves as read only thing and sometimes allows you to 
change it.
  You can actually change LL inside the "repeat for each" loop but if 
you are using "put AFTER" it fails.



on mouseUp

   Put "N,33,2,No Answer" into line 1 of TestLog
   Put "N,11,0" into line 2 of TestLog

   repeat for each line LL in TestLog

     -- put comma after LL -- Would NOT work
     -- put 5 after LL -- Would NOT work

     -- delete last char of LL -- works
     -- add 10 to item 2 of LL -- works
     -- delete last item of LL -- works
     -- replace "No Answer" with "NO Answer yet" in LL -- works
     -- put "OneMoreItem" into item 5 of LL -- works

     put LL & cr after tTest1
     add item 2 of LL to tTest
   end repeat

   put tTest & cr & ttest1

end mouseUp

best regards
Tariel




More information about the metacard mailing list