Page 1 of 1 1
Topic Options
#79961 - 2001-04-19 01:01 PM SELECT - CASE - ENDSELECT
Tan Bandradi Offline
Fresh Scripter

Registered: 2001-04-17
Posts: 31
It would be helpful and more well understood to add CASE ELSE option to this command, thus the command syntax will be something like this:

SELECT
CASE expression
statement1
....
CASE expression
statement2
....
CASE ELSE
statement3
....
ENDSELECT

Tan

Top
#79962 - 2001-04-19 04:55 PM Re: SELECT - CASE - ENDSELECT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
but you allready have an option for this.

code:

Select
case $a = 1
...
case $b = 2
...
case 1
(this case is always true, so always make it the last case statement so that it will be ran after all of the other case's are false)
endselect


Bryce

------------------
kix.isorg.net

[This message has been edited by Bryce (edited 19 April 2001).]

Top
#79963 - 2001-04-19 05:06 PM Re: SELECT - CASE - ENDSELECT
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I think he means change the "1" to "ELSE" to be more like other commands like IF...ELSE...ENDIF and other languages.

cj

Top
#79964 - 2001-04-19 05:38 PM Re: SELECT - CASE - ENDSELECT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
how about this...

select
case $a=1
case $b=2
case "else"
? "(this case is always true) "
endselect

Bryce

------------------
kix.isorg.net

Top
#79965 - 2001-04-24 01:22 PM Re: SELECT - CASE - ENDSELECT
Anonymous
Unregistered


I also don't see this as a big deal but if a change was to be made perhaps for real clarity instead of CASE ELSE we might have DEFAULT.
Top
#79966 - 2001-05-01 03:47 PM Re: SELECT - CASE - ENDSELECT
Anonymous
Unregistered


Personally I think 'CASE 1' is sufficient, but if there needs to be another command may I suggest OTHERWISE as in the following:
SELECT
CASE $a = 1 (code segment)
CASE $b = 2 (code segment)
OTHERWISE (code segment)
ENDSELECT

Top
#79967 - 2001-05-03 01:37 AM Re: SELECT - CASE - ENDSELECT
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I would like to suggest that SELECT be changed to this format, and I know this would not be backwards compatible but...

SELECT CASE $var

CASE "value1"

CASE "value2"

CASE ELSE

ENDSELECT

This means that this SELECT looks at $var only and you cannot have CASE $var1="value" and $var2="value" commands.

The advantage is that you no longer need to do this:

$var=rnd(10) or $var=anything that you only want to read once.

SELECT
CASE $var="value....

etc

This is the same as the (now fixed) problem of not being able to use SPLITs output...

I want SELECT to only require ONE reference to the source, be it a var or function.


cj

Top
#79968 - 2001-05-03 02:23 AM Re: SELECT - CASE - ENDSELECT
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Don't change the Select statement, it is very powerfull now!
It makes it out for a lot of If-Else-EndIf statements whitout a
skip/goto/exit statement.


cj-

This will only increase your code a bit, but it uses the current syntax,


$SelVar = $Value
; Could be : $SelVar = Rnd(10)
Select

CASE $SelVar = "value1"

CASE $SelVar = "value2"

CASE 'ELSE'

ENDSELECT

Erik

Top
#79969 - 2001-05-03 06:58 PM Re: SELECT - CASE - ENDSELECT
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I already do that, but I wanted to change things a bit.


cj

Top
#79970 - 2001-05-04 11:40 AM Re: SELECT - CASE - ENDSELECT
Anonymous
Unregistered


Having used both methods in other languages I must say that I would much prefer the very minor extra coding involved in the Kixtart approach for the vast degree of versatility and flexibility it offers. A minor, but still useful, advantage of the Kixtart approach is that when examining large and/or complex scripts it is so much more obvious what is being tested.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.058 seconds in which 0.025 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