The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ELSE issue? (*solved*)
#1
Have you had enough of me yet? :-D

I'm having a weird issue with ELSE, but I'm not sure if I'm doing something wrong or not. Take a look at this test program:
Code:
dim num as ubyte cls num = 1 test() num = 2 test() num = 3 test() num = 4 test () sub test IF num = 1 THEN PRINT "1" ELSEIF num = 2 THEN PRINT "2" ELSEIF num = 3 THEN PRINT "3" ELSE PRINT "X" END IF PRINT "---" end sub

I would expect the output from this to be like this:
Code:
1 --- 2 --- 3 --- X ---

But it's actually like this:
Code:
1 --- 2 --- 3 X --- X ---

Condition "3" is running correctly, but the final ELSE block is also being processed so you get two lines output if num is 3. Have I messed up the syntax there? The behaviour is certainly different to how it used to be, as an old program that used to be okay is now failing.

I've tried this in 2100 and also 1866 and it does the same in both, so it must've been a while since I compiled it! :-)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)