[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Help with select case...

Help with select case...

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Cogitator_Tertius   (3 posts)  [Biography] bio
Date Sun 19 Dec 2004 04:35 AM (UTC)
Message
My script uses select case to compare a variable against a list of possible matches. What I want to get the script to do is, in the case that there is no match, return a list of possible matches. However, I am using select case to compare my variable to the list of destinations.

For example:

select case ucase (sTarget)

case "HOME"
iGo "3s3ne"

I have quite a lengthy list of destinations, and would therefore prefer not to have to compile a list manually. The question is, what would I need to do in order to have the script echo a list of all possible matches? Also, would it be possible to restrict the echo to all matches starting with a given letter?

For example:

I input "(alias name) d" and the script returns all possible matches that start with D?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 19 Dec 2004 07:12 PM (UTC)
Message
I think you need to ditch the "case" statement and move to a loop which passes over a list of possible matches. That way you can then redisplay the list if it doesn't match, and it is easier to add to.

In the exampscript.vbs file that ships with MUShclient is an example of that sort of thing. There is an OnTeleport subroutine that lets you teleport to a named location, but if you don't enter the location it echoes all possible ones. You could modify that to accept a prefix.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Cogitator_Tertius   (3 posts)  [Biography] bio
Date Reply #2 on Thu 13 Jan 2005 12:04 AM (UTC)
Message
Ok.

I suppose I should clarify my question a bit. I have no problem getting it to echo all possible locations, but how do I get it to list all possible locations based on a list?
I.E. I have a list of all the locations which I have entered data for, but they use the select case command. I want to modify this list so that using echo I can get every entry on that list, but not every possible destination in the world.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #3 on Thu 13 Jan 2005 08:22 AM (UTC)
Message
You can use a 2x1 array, and loop through it each time, checking the first row. If it doesn't find anything, you can loop through it again, displaying the first row, so you will get a list of all the entries but not the directions. Is that what you wanted?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Beale   (35 posts)  [Biography] bio
Date Reply #4 on Thu 13 Jan 2005 12:31 PM (UTC)
Message
Or, in VBScript, a Dictionary object. (An Associative Array, table or Hash to other people. :))
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #5 on Thu 13 Jan 2005 03:37 PM (UTC)
Message
You can enumerate the Dictionary keys?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Thu 13 Jan 2005 08:58 PM (UTC)
Message
If you couldn't, it'd be a kinda dumb dictionary object. :P (Then again, knowing VBscript, that wouldn't surprise me...)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #7 on Fri 14 Jan 2005 10:24 AM (UTC)
Message
Hmm, true :p

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Cogitator_Tertius   (3 posts)  [Biography] bio
Date Reply #8 on Mon 24 Jan 2005 05:08 AM (UTC)
Message
Thanks.

However, being the complete incompetent that I am, I have yet another question.

I realize that the answer is probably floating about somewhere on the net, but I thought I'd ask here first.

Ok, assuming that I create a dictionary object, and I enter all my possible destinations. This leaves me with two problems:

1. I am not able to enter multiple strings for each "letter" in the dictionary. If I do, this leads to problem 2.

2. I have multiple values in each dictionary object, is there any way to call a different string for each key within the dictionary. IE:
"a" - "AA, AB, AC"
can I tie each one to a different key within the dictionary object, or do I need to do this outside the dictionary?

Thanks
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,907 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]