Craig, Jacque, et al: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.
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
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!
