Complex IF Blocks


ELSEIF is just this:

IF a% = 3 THEN
PRINT "Three"
ELSE
IF a%=5 THEN
PRINT "Five"
ELSE
PRINT "Not five nor three"
END IF
END IF


translates to... (faster to write)

IF a%=3 THEN
PRINT "Three"
ELSEIF a%=5 THEN
PRINT "Five"
ELSE
PRINT "Not five nor three"
END IF


I don't see why it is evil, but there is a better form:

SELECT CASE a%
CASE 3:
PRINT "Three"
CASE 5:
PRINT "Five"
CASE ELSE:
PRINT "Not five nor three"
END SELECT


You'll only notice the speed increase if you need to evaluate things in a long loop (for example, in a game loop).


ComplexIfBlocks - page last edited 2003-04-13 05:43:12 by 81.203.196.11 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster