Page 2 of 2

Re: Bad, bad broken SE

Posted: Thu Mar 10, 2022 7:25 pm
by RCozens
RCozens wrote: Wed Mar 09, 2022 8:05 pm I have changed the name of the string to "boardMix", made it a global instead of a local variable and placed the replace command in a function; but the SE now shows the replace command working as it should.
Craig, Jacque, et al:

What I had not done was pass boardMix as a parameter to the function. Without seeing Craig's code I cannot be sure what I've found is the source of the "error"; but it demonstrates a possible answer: if boardMix is passed by value, its value in the SE will not change until the function ends.

Here's my code:

Code: Select all

global boardMix

function replaceIt theString
   replace space with "." in theString
   return theString
end replaceIt

function replaceIt2 @theString
   replace space with "." in theString
   return theString
end replaceIt2

on mouseUp
   put field 2 into boardMix
   put empty into field "New String"
   put replaceIt(boardMix) into boardMix
   put boardMix into field "New String"
   put field 2 into boardMix
   put empty into field "New String"
   put replaceIt2(boardMix) into boardMix
   put boardMix into field "New String"
end mouseUp
I placed breakpoints at both function calls and stepped into and out of the functions.
The SE shows boardMix changes immediately in replaceIt2, where it is passed by reference; but not until replaceIt (which is passed the string by value) is stepped out of.

Cheers!

Re: Bad, bad broken SE

Posted: Thu Mar 10, 2022 8:29 pm
by dunbarx
Hi.

My handler passed by value. You have done far more work on this than I have. Mine fixed itself. Don't know why, I do not ask.

But until it goes south again, I cannot contribute to my own thread. :roll:

Craig