Schrodinger's Parameters
-
Hello all. I'm having trouble testing for valid/existing parameters in a macro. I can't seem to test if they are null, and the 'exists' function is like Scrodinger's cat - it just returns a yes no matter what I ask it!
This is on a 6HC running RRF 3.4b6 in SBC mode, set as a printer not CNC. Here is the test macro (sorry, don't know how to get it to display on the forum with indentation):
; test.g
; testing macro parameters;If {param.Z} = null
; abort "ABORT - missing Z."
If exists {param.Z}
echo "Got Z!"
If {!exists {param.Z}}
abort "Not got Z!"
if !{{param.Z} < 100}
abort "ABORT - Invalid Z position."
echo "Tests passed"This is the result with and without providing the Z parameter:
If I comment out aborting for !exists then this is the result without Z:
Any suggestions? Ideally I need a solution that works for numbers and strings please. Many thanks.
-
@theolodian You are using
exists
and braces in the wrong way. Try this instead:; test.g ; testing macro parameters ;if param.Z = null ; abort "ABORT - missing Z." if exists(param.Z) echo "Got Z!" if !exists(param.Z) abort "Not got Z!" if !{param.Z < 100} abort "ABORT - Invalid Z position." echo "Tests passed"
-
Thanks, however same result.
-
@theolodian Use a small i instead of the capital I in if
-
Ah, this is because of autocorrect doing this from a hotspotted iPad!?! Mind blown...
Thanks a ton!
-
-