Page 1 of 1 1
Topic Options
#13838 - 2001-11-01 01:27 PM Syntax if-else-endif
Anonymous
Unregistered


What is the correct syntax for the if-else-endif-statement?

1.

code:

If
;code
Else If
;code
Else If
;code
Else
;code
EndIf


2.
code:
If
;code
Else
;code
Else
;code
Else
;code
EndIf

3.

code:

If
;code
Else If
;code
Else If
;code
Else If
;code
EndIf

Thanks, Martijn

[ 01 November 2001: Message edited by: MartijnL ]

[ 01 November 2001: Message edited by: MartijnL ]

Top
#13839 - 2001-11-01 02:11 PM Re: Syntax if-else-endif
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
None of the above.

You cannot construct the code in the way you are trying. Every "IF" must have an "ENDIF", every "ELSE" must have an "IF".

You'd be better off looking at "SELECT /CASE / ENDSELECT" for complex conditional constructs.

code:
Select
CASE expression1
statements;
CASE expression2
statements;
CASE 1
default statements;
ENDSELECT

[ 01 November 2001: Message edited by: Richard Howarth ]

Top
#13840 - 2001-11-04 09:01 PM Re: Syntax if-else-endif
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

A possible structure with if/else/endif can be:

code:

IF condition_a
code
ELSE
IF condition_b
code
ELSE
IF condition_c
code
ELSE
code ; -in all other cases-
ENDIF
ENDIF
ENDIF


The select/case/endselect structure has the same effect and
is easier to read.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

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 (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.053 seconds in which 0.023 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