Page 1 of 1 1
Topic Options
#122238 - 2004-07-07 03:32 AM Else statements
DavidR Offline
Fresh Scripter

Registered: 2002-06-10
Posts: 10
I need to know if this is possible. I want to say something like:

if @producttype="Windows XP Professional"
configure proxy settings this way

else
if ingroup("Internet")
configure proxy settings this way

else
configure proxy settings this way
endif

Can I use ELSE like that ? I've never tried to use it more than once.

Thanks for all of the input on my last post :-)

Top
#122239 - 2004-07-07 03:42 AM Re: Else statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You can use ELSE but not quite the way you are doing. You are nesting IFs which is fine but every IF needs its own ENDIF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122240 - 2004-07-07 03:43 AM Re: Else statements
DavidR Offline
Fresh Scripter

Registered: 2002-06-10
Posts: 10
So if I put the endif between the other two statements if will be fine ?
Top
#122241 - 2004-07-07 03:49 AM Re: Else statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Post your revised code in code brackets with indenting.
Code:
IF $Whatever

'do stuff'
ELSE
IF $somethingElse
'do something else'
ELSE
IF $NoneOfTheAbove
'do this'
ENDIF
ENDIF
ENDIF

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122242 - 2004-07-07 04:17 AM Re: Else statements
DavidR Offline
Fresh Scripter

Registered: 2002-06-10
Posts: 10
I see now. I usually put the endif at the end of each statement instead of all at the bottom of the section.
Top
#122243 - 2004-07-07 04:34 AM Re: Else statements
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Examine the structure closer. The ENDIF's are not at the bottom of the section. Each one is associate with a particular IF. The indented structure is the key to readability of the NESTED IF statements.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#122244 - 2004-07-07 04:49 AM Re: Else statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Since the IF conditions are mutually exclusive, a SELECT-CASE-ENDSELECT would be more appropriate.
_________________________
There are two types of vessels, submarines and targets.

Top
#122245 - 2004-07-07 05:01 AM Re: Else statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Right you are Jens. I was so involved in laying out the indenting that I did not even notice.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122246 - 2004-07-07 05:02 AM Re: Else statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Ah, I'm slowly getting back up to speed in Kixtart matters ;-)
_________________________
There are two types of vessels, submarines and targets.

Top
#122247 - 2004-07-07 05:11 AM Re: Else statements
DavidR Offline
Fresh Scripter

Registered: 2002-06-10
Posts: 10
???
I've never used SELECT-CASE-ENDSELECT. Does that do the same thing only better ?

Top
#122248 - 2004-07-07 05:17 AM Re: Else statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
SELECT CASE is preferred when they are mutually exclusive.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122249 - 2004-07-08 04:40 AM Re: Else statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the Kixtart Manual for the difference between IF-ELSE-ENDIF and SELECT-CASE-ENDSELECT
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.067 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org