Page 1 of 1

Less Than, Greater Than

Posted: Thu 04 Apr 2019, 15:48
by MattC

I was just playing around with a loop which required a value of a variable to be between two values. The normal way seems to be a double expression, i.e.

UNTIL A% > 10 AND A% < 20

Is there any way a combined expression could be used? I.e.

[ UNTIL 10 < A% < 20 ]

I tried playing around with various formats/parentheses, but was unable to come up with any combination that worked. Is this one of those examples that just wont work in BASIC?


Re: Less Than, Greater Than

Posted: Fri 05 Apr 2019, 07:54
Hi Matt,

In that case, I guess you could use

UNTIL ABS(15-A%)>4

...but I'm not sure it would be significantly faster, and I'm fairly sure it's significantly less clear (and you have to be more careful about boundary conditions), so I'm not sure I'd recommend it.

Best wishes,


Re: Less Than, Greater Than

Posted: Mon 08 Apr 2019, 12:27
by p_m21987
DDRM is right. It's best to just write A% > 10 AND A% < 20.