Add a function to check if a number is inside a range
This isn't really necessary in normal programs but could be helpful for 10 liners. No idea what it would take to do it :)
I often find myself wanting to check a range of numbers (eg. check if a screen character is an enemy or a wall etc.) . The code usualy goes something like:
IF PEEK(S)>10 AND PEEK(S)<15......
It would save a fair bit of space if I could do:
IF PEEK(S)=11 TO 14
Compressed the lines are:
IFP.(S)>10ANDP.(S)<15 IFP.(S)=11TO14
This would save 7 bytes (8 if you could use a sign instead of TO). My current 10 liner uses this 6 times so that could be a saving of 48 characters.
There's probably a very good reason why this isn't possible, but it would be great if it could be done.
Hi!
I often find myself wanting to check a range of numbers (eg. check if a screen character is an enemy or a wall etc.) . The code usualy goes something like:
IF PEEK(S)>10 AND PEEK(S)<15......
It would save a fair bit of space if I could do:
IF PEEK(S)=11 TO 14
Yes, but I don't like that syntax very much. The simplest is to add a function (don't really like this name either):
IF BOUND(PEEK(S), 11, 14)
What function name do you think would be appropriate? BOUNDED? IN?
Compressed the lines are:
IFP.(S)>10ANDP.(S)<15 IFP.(S)=11TO14
This would save 7 bytes (8 if you could use a sign instead of TO). My current 10 liner uses this 6 times so that could be a saving of 48 characters.
You can compress the above much more:
IFP.S>10A.P.S<15
Remember that operators (AND/OR) also can be abbreviated, and you can omit function parenthesis.
Thx, I missed the note about AND (A.) abbrev. I was going to read about parenthesis, I knew something had happened with them :)
If you use BOUND i'm guessing that abreviates to BO. unless you're gonna swap it with BYTE(B.), and assuming parenthesis can be excluded then it would compress down to:
IFBO.P.S,11,14 (14 char) IFP.S>10A.P.S<15 (16 char)
So even given my new found compressing skills it's still a 2 char saving. Not earth shattering but a litte bit :)
BOUND seems ok, I like it better than IN, and the only other keyword I can think of atm is RANGE.
Given that it doesn't save as much as I thought it would, and that it doesn't really improve the readbility of standard code, I'd say this was a low priority - I'm sure there's other things the can use your time and bytes better.