Script editor oddity

dunbarx at aol.com dunbarx at aol.com
Fri Apr 19 09:21:40 EDT 2013



>From the forum...


Yipes. Confirmed here. I never saw this before. I wonder if it happens in Hypercard.


Given a field with some text in it and a button with:


on mouseUp
   select after char 3 of fld 1
   put "xx" after the selectedChunk
end mouseUp


If you put a breakpoint in, say, the "select..." line, you will get "put "xx" after the selectedChunkxx" after you step through.


Running the script works as advertised. 


EDIT:


In HyperCard, stepping through puts the text in the field, not in the script editor line.


Craig Newman
 
--------------------------------------------------------


Well, this may not be a trivial thing.


Again, make a field with some text in it, and a button with:


on mouseUp
   select after char 3 of fld 1
   get the selectedchunk
   
   put "XX" after it
   do "put XX after" &&  it
end mouseUp


Run, (do not step) through,with the following:


1- Comment out the "do" line, and nothing happens.
2- Comment out the "put" line, and the "xx" is inserted correctly in the field.
3- Comment nothing, and an error is thrown, because the variable "it" now contains the chunk reference, but with "XX" appended:


char 4 to 3 of field 1XX


Now you will debug, the offending line being the "do" line. The code in the script editor has been modified when this sequence runs. The variable "it" has had the "XX" appended to it, just as it did when the earlier code was stepped through (though not when it was run), and the "do" line therefore breaks.


How has this not popped up before?


Craig Newman

 



More information about the use-livecode mailing list