boolean expression problem, or documentation request
-
HW - DUet3 6HC
RRF 3.6.0-rc.2I'm getting a little bit fancy developing a macro to help me run some tests on my printer. I've just run into a situation where I the boolean-expression in an IF statement that is evaluating whether a string is equal to an integer. For example:
if "some_string" = 1
I expected this to evaluate to false - a string can never equal a number. But I get an error message:
Error: in file macro line 1 column 14: meta command: cannot convert operands to same type If my assumption is bad about this expression evaluating to false, then maybe the meta command doc should say something about this.
-
@mikeabuilder RRF takes the view that when comparing values for equality, you should know what the types are, therefore it is a static error if you compare different types. It's the same as evaluating
"some_string" + 1
. An exception is if you check a value for equality with the constantnull
because there are some values in the Object Model may be null or may have a value. -
@dc42 - thanks for explaining that. In my use case, I was building an array to fill in later with numbers and was using text as a placeholder when I created the array. I switched to null as my placeholder and now it works great.
-
@mikeabuilder I'm glad you got it working. I have updated the documentation.
-
-