Global variables stopped working
-
Hello. I have a program running on my duet 3 6HC running the stable release of 3.4 and it was working using a variable called global.loop. Then I tried to change my touch screen rotation and now the variables don’t seem to work.
Set global.loop = true
Just give me an error saying “error: unknown variable ‘global.loop’.
Everything was working.
Any thoughts?
Thanks.
-
Have you confirmed it's showing in the Object Model Browser?
It would be in ObjectModel.Global node.
I'm not sure if this makes a difference or helps, but my global variables are configured like this (there's no "." between global and PausePress, for example):
; Variable definition global savedSpindleSpeed = 0 global PausePress = false
-
@nightowl999 I think I figured it out. I'm not too good with the doccumentation and I must have enabled it at somepoint using the
global loop = false
I thought the doccumentaion said you just needed to
set global.loop=false
so I have added the global loop = false to my config.g so it is there when it starts up.
-
@baird1fa said in Global variables stopped working:
@nightowl999 I think I figured it out. I'm not too good with the doccumentation and I must have enabled it at somepoint using the
global loop = false
I thought the doccumentaion said you just needed to
set global.loop=false
so I have added the global loop = false to my config.g so it is there when it starts up.
Before you can use a variable you have to declare it like this:
global some_variable_name or var some_variable_name
Notice there is a space character (or tab) between the two words but not a period character.
To set the value of a variable you use this:
set global.some_variable_name = 123
Notice the word set and the period character.
To use the value of the variable you use the same pair of words with the period character.
if global.some_variable_name = 123
Frederick
-
You could set the variable within the config.g file, once the variable has been defined, but you'd usually set the variable within a macro.
So for example, I've defined the variable in config.g here...
; Variable definition global PausePress = false
...then set the variable in the macro file like this...
set global.PausePress = true
...which in this case changes the value from 'false' to 'true'.
-
@fcwilt @Nightowl999
These would make excellent additions to the documentation on how to use variables. The examples of how to use them are not the clearest. For instance the use of the space rather than the "." I really struggled with this. I ended up assuming that I needed to use set for global variables whether declaring them or just using them. I kept getting an error for G (lobal) not a valid command.
-
@baird1fa said in Global variables stopped working:
@fcwilt @Nightowl999
These would make excellent additions to the documentation on how to use variables. The examples of how to use them are not the clearest. For instance the use of the space rather than the "." I really struggled with this. I ended up assuming that I needed to use set for global variables whether declaring them or just using them. I kept getting an error for G (lobal) not a valid command.
I forgot to mention: I put all of my global variables in config.g so they are ready to use right after the printer is powered up or reset.
Frederick
-
-