A minor suggestion, but one that has proved useful in the past - to be able to use AND to do actions depending on whether the operand is true - see example code:
x=INTEGER(RND(50))
PRINT 100,100,"Number is "+("less than 25" AND x<25)+("equal to 25" AND x=25)+("more than 25" AND x>25
or
x=0+(10 AND something)+(20 AND somethingelse)+(50 AND anotherthing)
Just an idea for more efficient coding .....
uhm... that's what AND does, no?
AND is a logical AND. bAND is a binary one.
Yes and no. If you take my first example, currently you would have to code:
x=INTEGER(RND(50))
IF x<25 THEN PRINT 100,100,"Number is less than 25"
IF x=25 THEN PRINT 100,100,"Number is equal to 25"
IF x>25 THEN PRINT 100,100,"Number is more than 25"
but using the more flexible AND, you are can neaten things up to just one line of logical arguments. It becomes less like a boolean operation, and more like a subtext of the IF.
Like I said, it is only a minor suggestion, and only makes for neater coding
Ah. Now I see the thing.
You might want to do it this way:
x=RND(50) // RND is Integer
compare=25
PRINT optn(xcompare, "greater") + compare,100,100
FUNCTION optn: state, str$
IF state THEN RETURN str$
RETURN ""
ENDFUNCTION
This is a bit more readable (for me at least)
Kind of - let me give you a game like example.
Let's say we have a player as position px,py.
He has screen boundaries of minpx, maxpx, minpy, maxpy, and moves 1 pixel at a time.
Control is with the cursor keys.
So this code:
px=px+(1 AND KEY(205) AND pxminpx)
py=py+(1 AND KEY(208) AND pyminpy)
would check keypresses, ensure the player is sticking within the boundaries, and update his position, all in 2 lines of code. Hopefully that will give you a better idea of how it can be beneficial?
As I said, it's no biggie - but I do remember back to the days of coding with 1K to play with .... :)
This should work. Doesn't it?
Only ("test" AND a>b) does not work. (Strings can't be AND'ed)
Ah, okay - yeah, that does work - it's only strings that can't be ANDed - you're right
I tried with strings the first time, it didn't compile, so I assumed that the whole "ANDing" bit was non functional. As they say, assumption in the mother of all f*** ups :)