PDA

View Full Version : Why doesn't my 'if/else' statement work?


danfloun
02-13-2005, 11:55 AM
I am simply trying to display a message with the users operating system name in it. Using 'if' on it's own works fine but when I add 'else' it doesn't.
Can anyone show me a better way or explain why 'else' isn't working.

This works:

osresult = System.GetOSName();
if osresult == "Windows XP" then
Dialog.Message("Your OS is..", osresult);
end

This doesn't:

osresult = System.GetOSName();
if osresult == "Windows XP" then
Dialog.Message("Your OS is..", osresult);
else
if osresult == "Windows 2000" then
Dialog.Message("Your OS is..", osresult);
end

I know its easier to just use:

osresult = System.GetOSName();
Dialog.Message("Your OS is..", osresult);
end

but I am just testing a few things and my final code will not display the operating system but I just need to know why my 'else' steatement isnt working.

Thanks

Absynthe
02-13-2005, 02:36 PM
this code by itself will not compile

osresult = System.GetOSName();
if osresult == "Windows XP" then
Dialog.Message("Your OS is..", osresult);
else
if osresult == "Windows 2000" then
Dialog.Message("Your OS is..", osresult);
end
this will

osresult = System.GetOSName();
if osresult == "Windows XP" then
Dialog.Message("Your OS is..", osresult);
elseif osresult == "Windows 2000" then
Dialog.Message("Your OS is..", osresult);
end

danfloun
02-13-2005, 03:33 PM
Absynthe thank you.

That works great. I tried finding it in the help files but couldn't, just a little space that caused the problem, oh well. Thanks again. :)