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?
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.
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.
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?
Or, in VBScript, a Dictionary object. (An Associative Array, table or Hash to other people. :))
You can enumerate the Dictionary keys?
If you couldn't, it'd be a kinda dumb dictionary object. :P (Then again, knowing VBscript, that wouldn't surprise me...)
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