This is possible but you have to reload the script. If you’re new to scripting then it might be best to avoid this method until you feel more confident. The main reason is that all your variables will be lost unless you write them to memory so that they are available to the script when it reloads. If you want to give it a go, have a look at TVeyes’ suggestions on memory blocks in the code samples thread at the top of this forum.
Here’s some code to get you started:
[VarDef,text,"First text "]
[VarDef,OnOff,0]
//initialize code to set appropriate button text:
[If,[MemGetSize,GM_textchange],
[VarSet,OnOff,[MVarGet,GM_textchange,0]]
[If,[Var,OnOff],[VarSet,text,"Second text"]
,//else
[VarSet,text,"First text "]
]//end if
,//else
[MVarDef,GM_textchange,1][MVarSet,GM_textchange,0,0]
]//end if
[IButton,text,"Info text",
[Note,"Hello world"]
]
[IButton,"Change button text",,
//code for changing text follows. This could be in a routine.
[If,[MVarGet,GM_textchange,0],
[MVarSet,GM_textchange,0,0],
[MVarSet,GM_textchange,0,1]]
[IPress,zscript:reload]
]
I find it useful when testing code of this sort to add a temporary button to delete the memory block so that if I reload the script after changes it starts afresh. Otherwise you have to restart ZB to clear the memory.
EDIT: an alternative way of dealing with this would be to use a note interface. Check out Digits’ post in this thread . Using a note interface means you don’t have to reload the script. Depending on what you’re trying to achieve it may be a better way to go. My HEXcolor script (see sig.) is another example.