forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


SELECT Statement in VDS
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sun Oct 19, 2003 6:12 am    Post subject: SELECT Statement in VDS Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sun Oct 19, 2003 9:50 am    Post subject: Reply with quote

i agree with you here codescript...it would be very handy

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Oct 19, 2003 9:54 am    Post subject: Reply with quote

Here is some code which can do such a thing: Smile

http://forum.vdsworld.com/viewtopic.php?p=15320#15320

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sun Oct 19, 2003 6:16 pm    Post subject: Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Oct 19, 2003 8:40 pm    Post subject: Reply with quote

I know this is a dumb question, but what does a SELECT statement
do? Embarassed

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Sun Oct 19, 2003 8:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Sun Oct 19, 2003 8:57 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Oct 19, 2003 9:11 pm    Post subject: Reply with quote

Thanks for explaining to Protected. Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Oct 20, 2003 2:08 pm    Post subject: Reply with quote

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 Laughing I think I need to update it not sure.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Mon Oct 20, 2003 6:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Tue Oct 21, 2003 3:16 am    Post subject: Reply with quote

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 Embarassed

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Oct 21, 2003 5:27 am    Post subject: Reply with quote

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 Wink

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Tue Oct 21, 2003 8:12 am    Post subject: Reply with quote

i agree dr dread...it is a wish list Smile

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
View user's profile Send private message Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Oct 21, 2003 10:11 am    Post subject: Reply with quote

CodeScript, your wishes are very good ones. Don't stop them. Very Happy
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Tue Oct 21, 2003 10:50 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Wish List All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group