Ludii Forum
Initializing variables - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15)
+--- Thread: Initializing variables (/showthread.php?tid=522)



Initializing variables - Michael - 03-25-2021

Is there a restriction on where I can introduce a variable? I tried setting a variable inside (apply), but got the message "Could not match string 'MovesLeft'. Misspelt define or item?". Do I have to set the variable somewhere else first?


RE: Initializing variables - Eric Piette - 03-25-2021

Hi,

No restriction no. The error you got is the compiler does not find the String used to name the variable? Probably because you are using (set Var ...) with a name, but never (var ...) with the same name.
Can you send us a .lud example to check.

Eric


RE: Initializing variables - Michael - 03-25-2021

Hm. It seems related to the fact that I was setting two named variables inside (apply). I removed the string from the first one, and then it worked fine. I'll send a .lud shortly.

Here is the .lud. It compiles if I simply removeĀ "MovesLeft" from the first variable in (apply).


RE: Initializing variables - Michael - 03-25-2021

(03-25-2021, 08:21 AM)EricĀ Piette Wrote: Probably because you are using (set Var ...) with a name, but never (var ...) with the same name.
That wouldn't explain why the other named variable doesn't cause the same error when I remove the name of the first..