Error using the "If" Command

Dave Yrueta shared this question 1 year ago
Answered

Using the "If" command for writing scripts is producing strange errors. After defining a point A and slider for n, the example copied from the Manual

If(Mod(n, 7) == 0, SetCoords(A, n, 0), SetCoords(A, n, 1))

also produces an error. Am I doing something wrong?

Thanks for the help!

Comments (3)

photo
1

It should be this way round:

SetCoords(A, n, If(Mod(n, 7) == 0,0,1))
If that doesn't help, please post your .ggb file

photo
1

What error message? What version of Geogebra?


I have just tried this same example, copying and pasting your command directly, and it worked fine for me:

/AcytvnVY2VyuAAAAAElFTkSuQmCC


Where are you placing the If instruction?

photo
1

Hi pisquared -- Thank you for posting your screenshot. That cleared up the problem. Defining A = Point({21, 0}) instead of A=(21, 0) produced the error. I thought Point objects needed to be defined in terms of bracketed lists.

© 2023 International GeoGebra Institute