PDA

View Full Version : Multiple Conditions in IF/THEN Statements



catventure
14-11-2005, 20:49
Hi,

Just checking about this:
Is it valid to do check several conditions inside a single IF/THEN statement like in the below code?
It seems to work logically and does not produce any errors when I alter the contents of variables b and c.....
If so, it's really great we can do things like this. What are the limits to using AND and OR in such situations?




dim b as long
dim c as string

b=34
c="some string"

if &#40;b>0 or b<2&#41; and b<>65 AND b<=34 AND c="some string" _
AND b=34 And c<>"another string" and instr&#40;c,"me"&#41;=3 then

msgbox &#40;0,"I am showing because the IF conditions are true"&#41;

else

msgbox &#40;0,"I am shown when the IF conditions are false!"&#41;

end if



Best wishes,
catventure.

ErosOlmi
14-11-2005, 21:23
Hi catventure,

your example is correct and valid but for some reason thinBasic hang.
If you avoid underscore _ and put all in one line it seems working fine.
So I think there is something wrong in the way thinBasic is concatenating multiline sentences.

Regarding limits, in theory you can mix any number of tests logically mixed with correct parenthesis if needed.

I will have a look this night, at the moment I'm not on my developent box.

Regards
Eros

PS: When solved I will move this into Bug forum because it is a bug :oops:

Petr Schreiber
14-11-2005, 21:24
Hi Catventure,

I'm using multiple test in single IF/THEN in my space game example and it seems to work good.

Your example doesn't make my PC hang ?!

Psch

ErosOlmi
14-11-2005, 22:11
catventure,

maybe did you copy and paste code from somewhere into your editor?
I have the impression some strange ascii char is between somewhere, maybe a null or something else.

I have check with an HEX editor to see what's happening.

I will give you back but I'm sure is not any logical test failing but some ascii char not correctly managed by thinBasic parser.

Eros

ErosOlmi
14-11-2005, 22:59
OK, I've found the problem. WHAT A PROBLEM !!! :twisted:
If underscore char _ is followed by a space thinBasic preprocessor hangs!!
Stupid me.

Please find here attached fixed thinCore.dll
I will release version 1.0.7.0 this night or max tomorrow.

Thanks for finding it.
Ciao
Eros