switch statement in GDL
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-01 08:52 PM
2007-04-01
08:52 PM
Is there a smart way to make a switch statement ala
switch var {
case 'example': DO SOMETHING;
case 'anotherex': DO SOME OTHER THING;
}
As far as I can see, I can't even do an ELSIF, so for now, I am left with the choice between potentially very deep nested IF-trees or letting control do the check for all possible values, no matter what.
I am a bit confused that it seems switching statements (or at least elseif) does not exist, as this is a a pretty essential feature for any programming language...
Wikipedia on switch statements
- Jeppe
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-02 12:04 PM
2007-04-02
12:04 PM
jeppe,
there is no switch or elsif like GDL command. I suppose you will have to get used to it mate. GDL is geometry oriented language and very specific to just one application so I do not think it should keep up with other broad scope programming languages in that part.
there is no switch or elsif like GDL command. I suppose you will have to get used to it mate. GDL is geometry oriented language and very specific to just one application so I do not think it should keep up with other broad scope programming languages in that part.
::rk
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-02 01:49 PM
2007-04-02
01:49 PM
IF THEN ELSE ENDIF
That's it.
That's it.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-02 03:16 PM
2007-04-02
03:16 PM
GDL is a pretty simple language. I've long hoped for it to at least get SOME modern abilities (like switch/case commands, autocompletion, and a real IDE)
Tom Waltz
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-02 03:44 PM
2007-04-02
03:44 PM
TomWaltz wrote:(and ability for one GDL object to place other independent GDL objects)
GDL is a pretty simple language. I've long hoped for it to at least get SOME modern abilities (like switch/case commands, autocompletion, and a real IDE)
(and a few standard functions on "Right click" that you could use in your object, like place new hotspots on a hotline to split it up, change attributes on hotline, then we would have ability to make more flexible but easy objects without advanced API hacking, I'm already having an idea that wouldn't be that hard to implement)
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2007-04-02 11:38 PM
2007-04-02
11:38 PM
To simulate the switch/case function I sometimes use something like:
This is functionally not much different than a simple series of IF THEN ENDIF statements but it is sometimes easier to read and maintain. It does avoid reading any subsequent conditions after it finds a match which is either a bug or a feature depending on the circumstances.
IF something GOTO 10 IF something_else GOTO 20 IF another_thing GOTO 30 10: DO make_hay !...and so on WHILE the_sun = shine GOTO 1000 20: REPEAT the_impossible !...and so on UNTIL pigs = fly GOTO 1000 30: !__enough already! 1000: !__done with cases...
This is functionally not much different than a simple series of IF THEN ENDIF statements but it is sometimes easier to read and maintain. It does avoid reading any subsequent conditions after it finds a match which is either a bug or a feature depending on the circumstances.