On 17/02/2015 15:43, Bob Sneidar wrote:
Then past posts are incorrect on this matter. It was explicitly stated that the
actual memory holding the variable data was “indexed” and that altering the
variable data could relocate the variable in memory resulting in invalid data.
I have seen this myself. The data returned is garbled nonsense. I don’t think
setting the value of the variable back to what it was will correct this.
That is still consistent with what I described. What I am claiming (and
*all* I am claiming) is that the scan for the next line is incremental
rather than done once for all lines at the start of the loop. Whether
the engine does this by maintaining a "character offset" or a direct
memory pointer is way beyond the scope of my description/claim.
If (as seems likely) it does keep a direct memory pointer then it is
indeed very possible for that to explain the problem you describe - some
modification to the subsequent lines might require more memory than is
available in place, so a new larger memory block is created and the
string copied/expanded, and hence the pointer would become stale and the
result would be total garbage.
I am *absolutely* not recommending that anyone should modify the
variable in question within the loop - even if that seems to work in
some cases, it is known to be dangerous, and so should just NOT BE DONE
in "real" code. But doing it in limited cases does allow one to deduce
some things about how the engine is doing its tasks.
Of course, now that we have access to the open source, it's equally
possible to just go look. And if I ever have time to go through a github
tutorial, and get myself a copy of the source, I will try to do that and
be in a position to actually know what the engine does, rather than
deduce it indirectly. But I'm not holding my breath for when I'll have
that much free time :-)
-- Alex.
But I’ve been mistaken before.
Bob S
On Feb 16, 2015, at 18:05 , Dr. Hawkins
<doch...@gmail.com<mailto:doch...@gmail.com>> wrote:
On Mon, Feb 16, 2015 at 3:08 PM, Alex Tweedly
<a...@tweedly.net<mailto:a...@tweedly.net>> wrote:
That's not quite correct. It doesn't do a single initial complete scan of
the whole variable and keep all the pointers. What it does is (more like)
keep track of how far it has currently processed, and then when it needs
the next line, it scans from that remembered position forward until the
next CR - and then remembers that as the current position.
And if you repeat for each item, and change the itemDel in the loop, you
had *better* remember to change it back before end repeat, or very strange
things happen . . .
--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode