Using AND and OR in IF conditions seem to throw Syntax Errors (#20) in certain situations, e.g.,
if A$ and Anything_Else then print "OK"
Evidently, the string expression without a relational operator and comparison value has to be stand-alone:
if A$ then if Anything_Else then print "OK"
Does anyone know if this is the correct operation, or if both of these should work...?
Thanks, all!
The and operator is defined for numeric operands only. That is why x$ and y is an invalid expression. It's an operator like any other: You can write something like result = x and y. If the condition expression in an if statement is a string, it behaves like if not(nul(x$)) ... So to get the same effect like if x$ if y ... you can write if not(nul(x$)) and y .... You could also write if len(b$) and y or if b$<>"" and y but that's only checking for the empty string. if x$ also considers space-only strings false. It is also important to note that not(...) does only negate the boolean value of its parameter if it is numeric. When a string is passed to not(...) it inverts all bits. This means if x$ is not the inverse of if not(x$). So when using strings in a compound if expressions, you usually want to use nul(x$) or not(nul(x$)).