| View previous topic :: View next topic |
| Author |
Message |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sun Oct 19, 2003 6:12 am Post subject: SELECT Statement in VDS |
|
|
SELECT Statement in VDS
| Code: |
SELECT %%var
Case 1
......
Case 2
......
Case 3
......
Case 4
......
Case Else
......
ENDSELECT
|
I know these can be achieved using
IF ELSE statements in a more convoluted way
but when you need to select among large number
of available/possible options this may increase
efficeincy on part of both the programmer and the program. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sun Oct 19, 2003 9:50 am Post subject: |
|
|
i agree with you here codescript...it would be very handy
serge _________________
|
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sun Oct 19, 2003 6:16 pm Post subject: |
|
|
I know one can do a custom function like that, but each branching to a custom function takes time which is only a lttle less than time taken after a INFO box display.
Some may still disagree about this sluggishness but I have tested it, _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Oct 19, 2003 8:40 pm Post subject: |
|
|
I know this is a dumb question, but what does a SELECT statement
do?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Protected Valued Contributor


Joined: 02 Jan 2001 Posts: 228 Location: Portugal
|
Posted: Sun Oct 19, 2003 8:53 pm Post subject: |
|
|
SELECT %%AA
CASE 1
rem Do this
CASE 2
rem Do that
CASE Popcorn
rem Do something
ELSE
rem Whatever
END
would equal :
IF @EQUAL(%%AA,1)
rem Do this
ELSE
IF @EQUAL(%%AA,2)
rem DO that
ELSE
IF @EQUAL(%%AA,Popcorn)
rem Do something
ELSE
rem Whatever
END
END
END
If a select statement is too hard to implement in vds a similar (or even better) result could be achieved with ELSEIF since it would allow usage of functions other than equal...
IF @EQUAL(%%AA,1)
rem Do this
ELSEIF @equal(%%AA,2)
rem Do that
ELSEIF @equal(%%AA,popcorn)
....
ELSE
....
END |
|
| Back to top |
|
 |
Protected Valued Contributor


Joined: 02 Jan 2001 Posts: 228 Location: Portugal
|
Posted: Sun Oct 19, 2003 8:57 pm Post subject: |
|
|
Perhaps the most effective of all would be SELECT with a function that would be replaced by the CASE parameter, for increased flexibility, so the previous example would be:
SELECT @equal(%%AA,@selcase())
CASE 1
rem Do this
CASE 2
...etc...
END |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Oct 19, 2003 9:11 pm Post subject: |
|
|
Thanks for explaining to Protected.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Oct 20, 2003 2:08 pm Post subject: |
|
|
Hi All,
Well I guess no one remembers my mpSelect.dll that is free. It was my first VDS DLL and it has this already I think I need to update it not sure. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Mon Oct 20, 2003 6:20 pm Post subject: |
|
|
| Protected wrote: | If a select statement is too hard to implement in vds a similar (or even better) result could be achieved with ELSEIF since it would allow usage of functions other than equal...
IF @EQUAL(%%AA,1)
rem Do this
ELSEIF @equal(%%AA,2)
rem Do that
ELSEIF @equal(%%AA,popcorn)
....
ELSE
....
END |
I think this whole wish is quite pointless as starting from VDS 4, an "ELSIF" command is already
contained. The effect is quite the same as a true CASE structure and in my opinion the addition
of support for true CASE structures would be unwanted.
In native programming languages, with data types and such, it could be useful for
performance reasons, but because VDS is interpreted and does not support typed
data, this doesn't seem to apply to VDS. |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Oct 21, 2003 3:16 am Post subject: |
|
|
I think I should *really really* stop this wish thingy especially those wishes which are more of convenience kinda rather than a *absolute* need. This may drive away newbies/guest users thinking that VDS is not self sufficient/incomplete and even doesn't support this?? etc.
While fact is that VDS has grown into a language which can accomplish majic or miracle things even for a person who absolutely does not know even a single word about programming.
Also I think such silly wishes might have even cast doubts about my sincierety/respect to VDS which isn't true.
Anyway enough of wishing here  _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Oct 21, 2003 5:27 am Post subject: |
|
|
| CodeScript wrote: | | I think I should *really really* stop this wish thingy especially those wishes which are more of convenience kinda rather than a *absolute* need. |
I think you're being too humble, CodeScript. This is a wish list, and one may wish whatever one wants!
You may wish a brand new BMW for your birthday or a little convenient feature in VDS - if your wish is a good
one it may come true one day
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Tue Oct 21, 2003 8:12 am Post subject: |
|
|
i agree dr dread...it is a wish list
in defence of codescript, i would prefer the syntax of SELECT and CASE rather than IF and ELSIF even though the latter can do the former...i think that having it built in would be a nice addition...me thinks...
serge _________________
|
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Oct 21, 2003 10:11 am Post subject: |
|
|
CodeScript, your wishes are very good ones. Don't stop them.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Oct 21, 2003 10:50 am Post subject: |
|
|
I think if this were to be implemented in VDS it would be something like:
GOTO <label1>, <label2>
where <label1> could be a variable, and <label2> is where it would go if the label didn't exist. The interpreter has to have a label to go to.
But you can achieve the same thing using the existing GOTO, setting OPTION ERRORTRAP to cater for the ELSE case. I don't know if it would be possible to make a user-defined command to do this, in a way that looked more like a SELECT statement... _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
|