Weather / Spam / www |
Lyon Weather
aldweb against spam
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 1454 |
IF/THEN/ELSE behavior - finally figured it out |
23/09/2006 @ 23:02 by Dave O\'Brien
|
FYI, I just figured out what was causing a frustrating bug in my program.
I was using code like this:
IF A=B 'do something ELSE 'do something else ENDIF
It compiled just fine, but didn't work.
Took me a long while to realize I was missing the THEN keyword. As soon as I put that in, it worked properly.
In a future release of iziBasic, perhaps it would be useful to either: - make the THEN optional in IF/ELSE statements (like it is for IF statements without the ELSE), or - keep the THEN required, but generate a syntax error at compile time.
Thoughts? |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1 -------- 24/09/2006 @ 18:20 by aldweb
visitor |
Hello Dave,
You are right, the checks performed by the compiler are not 100% efficient with the IF statement and someone can get the bad side effect you got. It is then difficult to find back where the mistake is. I will have to enhance the iziBasic syntax checker in this area for the next release.
What you got as a side effect is because of the 2 syntaxes allowed for the IF statement: IF A=B Statement and : IF A=B THEN Statement [ELSE Statement] ENDIF
The first syntax is equivalent to the second one expressed this way: IF A=B Statement : ENDIF
In your code, this is how iziBasic interpreted it:
IF A=B : ENDIF ELSE Statement ENDIF Of course this has no chance to work!
Thanks for reporting, I'll work it for next iziBasic version.
Cheers,
@+ aldweb |
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|
|
|
|
|