comparing content of two fields
Pete
pete at mollysrevenge.com
Thu Apr 28 14:47:42 EDT 2011
In the past, I've dealt with this situation by writing the changed data out
to another variable within the repeat loop, so:
repeat for each line myLine in theLines
if dataNeedsChanging then
<change myLine>
end if
write myLine after theNewVariable
end repeat
put theNewVariable into theLines
I'm guessing that's probably not as fast as using a copy of theLines and
changing it?
Pete
Molly's Revenge <http://www.mollysrevenge.com>
On Thu, Apr 28, 2011 at 11:20 AM, Scott Morrow <scott at elementarysoftware.com
> wrote:
> Hello Bob,
> --Earlier Scott posted:
> > on mouseUp
> > set the itemDelimiter to tab
> > put field "All" into tBigData -- use this to compare with field "Rural"
> data
> > put tBigData into tBigData2 -- we will change this data as matches are
> found
> > put field "Rural" into tSmallData
> > --<snip>
>
> This is why I put tBigData into a second variable tBigData2. Repeat for
> each uses tBigData and we change tBigData2. No conflict.
>
> Scott Morrow
>
> On Apr 28, 2011, at 10:40 AM, Bob Sneidar wrote:
>
> > It is absolutely faster. It was explained to me some time ago why. I
> think it still applies, although I have not tried to test it.
> >
> > It is because the engine works directly on the memory used for the object
> (or something like that). The problem is, the engine parses the memory and
> creates a list of pointers to each chunk that you are looping by. (Someone
> correct me if I am wrong about this.) If you change what is in that memory
> at any time in the repeat loop, the pointers to the chunks you are looping
> by do not update with it. So if the contents of the memory shift, the
> pointers no longer point to what you think they do.
> >
> > In the past I often got garbage in the each variable at some point,
> leading me to believe that the OS did some house cleaning and the contents
> of the memory block was no longer valid.
> >
> > That has been my understanding, but if I am mistaken, or something has
> been updated in the repeat for each algorithm, I'll be happy to know it.
> >
> > Bob
> >
> >
> > On Apr 28, 2011, at 10:01 AM, John Dixon wrote:
> >
> >>
> >>
> >>
> >>
> >>> Be careful with repeat for each. You cannot change the content of the
> object or block you are repeating through. "Unexpected results" is an
> understatement. You need to work with a copy, making sure you don't add or
> remove the each element (each word, each line etc.) else you get out of
> sync.
> >>>
> >>> Bob
> >>
> >> Using 'repeat for each' with a counter is still faster than 'repeat
> with'
> >>
> >> put 1 into count
> >> repeat for each line thisLine in fld 1
> >> if line count of fld 1 = whatever then doSomething
> >> add 1 to count
> >> end repeat
> >>
> >> be well
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
More information about the use-livecode
mailing list