How can I execute multiple command i.e: SetColor in an execute block

Dani shared this question 2 years ago
Answered

I tried executint multiple SetColor calls in one Execute block, and It showed the following error:

"Command SetColor:

Illegal Argument: Number 1

Syntax:

..."

The input I used was the following.

Execute[{

"SetColor(AC0, "Red") ",

"SetColor(AC1, "Red") ",

"SetColor(AC2, "Red") ",

"SetColor(AC3, "Red") "}]

AC0, AC1, and so on were points. I tried using other Set commands also and they did not work either.

My question is that was I misunderstanding something or is there any workarounds or is it a known issue that is to be addressed?

Best Answer
photo

Hi,

because with this syntax, "red" is a variable...

try :

Exécute[{"SetColor(AC0, 1,0,0) ","SetColor(AC1,1,0,0) ","SetColor(AC2,1,0,0) ","SetColor(AC3, 1,0,0) "}]

Comments (6)

photo
1

Hi,

because with this syntax, "red" is a variable...

try :

Exécute[{"SetColor(AC0, 1,0,0) ","SetColor(AC1,1,0,0) ","SetColor(AC2,1,0,0) ","SetColor(AC3, 1,0,0) "}]

photo
1

"red" is considered as a variable like "i" in the syntax :

Execute(Sequence("SetColor(AC" + (i) + ", 1, 0, 0)", i, 0, 3))

...

photo
1

Red="red" first should fix it 😀

photo
1

define additionally:

Red = UnicodeToLetter(34) + "RED" + (UnicodeToLetter(34))

because it must be a string (text) in execution see here and here.

This causes the variable Red to be inserted within the string "SetColor(.....)" when generating. This variable is a text that contains 2 apostrophes in the text itself. Thus it becomes a text when it is executed.

photo
1

Thank you very much for the fast answers.

I Tried making a variable Red = "red" first and it did not work. After I tried the other way with the three values, and it worked, which I am happy with. I tried to be sure the last suggestion with the Unicode but sadly I could not make it work in short time so I am going to stick with using the values.

photo
1

Alternative

© 2021 International GeoGebra Institute