Scripting command generates new variables

cemccourseware shared this question 1 year ago
Answered

I have placed a command similar to the following in a button script. Every time it is executed, and additional variable is created. Is there a way to avoid this? See the attached ggb file for an example.

Here's the scripting command I wanted to use:

If(G3CorrectFormat,ParseToNumber(H3,Take(G3NoBlanks, 3)),SetValue(H3,-9999))

Here's a simpler version of ithe command that also exhibits the same behaviour:

If(true,ParseToNumber(a,"123"),SetValue(a,-9999))

Comments (3)

photo
1

If(true,SetValue(a,ParseToNumber(a,"123")),SetValue(a,-9999))

(it's a exception. The sense of the first parameter in ParseToNumber is for me not clear)

photo
1

Thank you very much! That seems to have resolved the problem.

photo
1

the help of parsetonumber() says:

This is a scripting command which only sets the value of a number once. To convert a text text1 into a number which is updated dynamically, use FromBase(text1,10).


try If(true,SetValue(a,FromBase("123",10)),SetValue(a,-9999))

© 2020 International GeoGebra Institute