Small problem in the 'CheckUpper' function, it should be:
' Default to false
' If it's already uppercase, change to true
Function CheckUpper(ByVal strData)
CheckUpper = False
If (strData = UCase(strData)) Then CheckUpper = True
End Function
1) The code:
will take the data in 'strVarName' and pull out the first 9 characters starting at the beginning(left side) of the string.
In this case, all the variables you are looking for should start with "OCLRDATA_", so you can test the first 9 characters to match this.
If the variable name starts with this, then it will continue processing, otherwise it will ignore it and continue into the next 'for each' loop and grab the next variable name.
In this way you will basically check the names for ALL your variables you currently have, but only use the ones that start with that specific code. You could also put additional checks in if needed, say checking to make sure the length of the variable name is 9 characters long.
2) For Each strVarName in astrVarNames
If you look in the functionality for Mushclient, world.GetVariables will return a list(array) of all the names of all the variables it currently has stored. I store this list into 'astrVarNames'(array, string, Variable Names).
This specific command is formatted as such:
For Each <variable> In <array>
<... process using variable>
Next
So it will store the first variable name into 'strVarName' on the first loop, then process what is between the 'for each' and 'next' statements. When it finds the 'next' statement, it will jump back to the 'for each' statement and pull the next variable name out of the list and store it into 'strVarName'. It will continue to do this until it runs out of information from the list that is stored in 'astrVarNames', or until it sees an 'Exit For' command(which I don't use, but it's available).
For additional infomation on the 'For Each ... Next' statement as well as other VBScript functionality, you can always use the reference at the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vbscripttoc.asp
The 'For Each ... Next' statement can be found under the Statements link on the table of contents.
3) (\- AT [A-Za-z]+ \-)
With only 1 instance of what you wanted to match, some minimal guessing has to be made, and I guessed that 'AT' was going to be the only data right there, although that was incorrect. For better first runs on creating regular expressions, it's good to have several extremely different examples to match against so that all possibilities can be found.
Here's probably how you want it if you just want to match against 2 capitalized letters:
(\- [A-Z]{2} [A-Za-z]+ \-)
This will match 2(the reason for the brackets around the number 2) capitalized letters.
Alternatively, if you know the list of possible double letters and want to only check for them, you could use(as an example with the data you gave so far):
(\- (?:AT|BC|GL|UN|FC|CC|RV) [A-Za-z]+ \-)
This will limit it to finding only one of those pairs of letters.
You'll notice the (?:<data>) format. I think it was mentioned already, but this will cause the regex not to remember this data as something that it should store and return as one of the values, even though it is between a pair of parenthesis. Normally everything between parenthesis is returned as one of the items that the regex pushes back to be used. It is useful when you need to use something that is only easily available using the parenthesis(in this case, the ability to put a list of items to pick from), but don't want to return it with the normal data.
For other examples of using regular expressions, and advanced techniques, there is a file that is installed with MushClient called "RegularExpressions.txt" under the "doc" subfolder from where you installed MushClient.
4) 0-9s should be able to go into the hundreds
The current code would allow it to take any amount of numbers and periods in them. You can restrict this further, but unless you really don't trust your data, I'd leave it like this for simplicity for now.
5) last A-Z needs to have 4; there can only be D, S, M, F, J, m
You can change it from
to:
This requires 4 characters, but they can only be what's between the square brackets.
If you want to change this so it will allow anywheres from 1 to 4 characters, it would look like this:
But would still be limited to the characters between the brackets.
6) you never defined the strData
strData is defined in the Function line as follows:
Function CheckUpper(ByStr strData)
So when you call CheckUpper(<data>), whatever <data> is will be stored into 'strData'.
The following line:
If (strData = UCase(strData)) Then
basically compares the exact string you sent through against the same sting that has had all of its letters forced to be capitlized. If the letters in 'strData' are already capitalized, then forcing them to be capitlized won't change it, so they'll match. If any letters in strData are lower case, then it will change from a lower case letter to an upper case letter and they won't match anymore.
-----
I think that covers most of the questions so far.
Good luck. :) |