07-30-2017, 07:05 PM
LTee Wrote:In the original BASIC listing I was using it as a memory/time-saving way of selecting a colour based on the value of a variable.
e.g.
PRINT INK 1+(val<5);val
So if val>=5 the message prints in ink 1, but if it's less than 5 it becomes ink 2. Obviously this doesn't work out so well if the value is suddenly 255 instead of 1 or 0.
Yup. You'd have to wrap it in the SGN function, which I think should return 1 for positive numbers, 0 for zero, and -1 for negative numbers if you want to explicitly do that. It's a bit of a sinclair basic cheat, really. Languages that have an explicit boolean type wouldn't let you get away with this cheese either

I haven't tested, but try 1+SGN(val<5)
Though given VAL is a reserved word, that's a bad variable name choice btw.