Spécial ! |
Version mobile de l'aldweb Site m.aldweb.com Ni Français, ni Anglais ?Essayez donc l'un de ces drapeaux :
|
|
Météo / Spam / www |
Météo Lyon
aldweb contre le SPAM
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1454 |
IF/THEN/ELSE behavior - finally figured it out |
le 23/09/2006 @ 23:02 par 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
Réponse n° 1 -------- le 24/09/2006 @ 18:20 par aldweb
visiteur |
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 |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|
|
|
|
|