You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using either the terminal or running as a program:
if not (defined hdg) and not (defined hdg@) lock hdg to 90.
throws an error Undefined Variable Name 'hdg'.
If the code was not run as a program but input through the terminal prompt, checking for defined hdg afterward will result in the same error as above, while defined hdg@ is 'false'.
Interestingly, also after using the terminal prompt for the above code,
set hdg to 1.
print hdg.
print defined hdg.
unset hdg.
print hdg.
print defined hdg.
results in
1
false
1
false
and not
1
true
<error>
false
The text was updated successfully, but these errors were encountered:
In this line if not (defined hdg) and not (defined hdg@) lock hdg to 90. this (defined hdg@) jumps out at me as violating what should be done with defined as you are not using an identifier at that point but something more complex. Also while the documentation doesn't tell you this from what I remember defined only works well with vars and not functions and as locks are functions you are going to get issues.
As to the strangeness of this
set hdg to 1.
print hdg.
print defined hdg.
unset hdg.
print hdg.
print defined hdg.
after running the erroring command you are trying to set something that is was adjacent to a lock command which often leads to problems even if the lock didn't execute. The advice is to never set something you ever though about locking and never lock something you set for a very very good reason. It can work just fine most of the time but when it breaks does it ever explode.
"The advice is to never set something you ever though about locking and never lock something you set for a very very good reason".
Thats basically what the purpose of the line if not (defined hdg) and not (defined hdg@) lock hdg to 90 is. If the user has already defined or locked hdg use that, otherwise lock it to 90.
For anyone stumbling over this looking for a workaround, this
set locks to lex("hdg", false).
if not (defined hdg) and not (defined hdg@) locks:hdg on.
if locks:hdg lock hdg to 90.
seems to work just fine (and can be extended for additional var-checks).
Using either the terminal or running as a program:
throws an error
Undefined Variable Name 'hdg'
.If the code was not run as a program but input through the terminal prompt, checking for
defined hdg
afterward will result in the same error as above, whiledefined hdg@
is 'false'.Interestingly, also after using the terminal prompt for the above code,
results in
and not
The text was updated successfully, but these errors were encountered: