Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Help with select case...
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Cogitator_Tertius
(3 posts) 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,051 posts) 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 | Top |
|
Posted by
| Cogitator_Tertius
(3 posts) 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. | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) 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! | Top |
|
Posted by
| Beale
(35 posts) 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. :)) | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) 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! | Top |
|
Posted by
| David Haley
USA (3,881 posts) 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 | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) 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! | Top |
|
Posted by
| Cogitator_Tertius
(3 posts) 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 | 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.
26,878 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top