3031
Technical support / Re: Nested Parentheses in Logical Expressions
« on: May 02, 2003, 12:11:32 PM »
You are right that the current TBASIC compiler doesn't process complexed logical expression the way C language does. Basically a While expression expect a simple comparison expression that could be joined by an "AND" or an "OR" operator. It doesn't process logical expression within brackets (that may change in future). That's why terse expression like your example will not compile properly.
An equivalent expression is as follow:
I$ = INPUT$(1)
FOR I = 1 TO 20
X = ASC(strupr$(I$),1)
IF LEN(i$)=0 RETURN: ENDIF
IF ASC(strupr$(I$),1)<>65 AND asc(strupr$(I$),1)<>82
GOTO @5
ELSE
I$ = mid$(I$,2,len(I$)-1)
ENDIF
NEXT
@5 ' Out of loop location
An equivalent expression is as follow:
I$ = INPUT$(1)
FOR I = 1 TO 20
X = ASC(strupr$(I$),1)
IF LEN(i$)=0 RETURN: ENDIF
IF ASC(strupr$(I$),1)<>65 AND asc(strupr$(I$),1)<>82
GOTO @5
ELSE
I$ = mid$(I$,2,len(I$)-1)
ENDIF
NEXT
@5 ' Out of loop location