Okay, I have my script execute this Subroutine on a command.
Sub OCLR()
Dim astrVarNames
Dim strVarName
Dim astrDataSplit
world.note "Contact Information"
astrVarNames = world.GetVariableList
For Each strVarName In astrVarNames
If (Left(strVarName, 9) = "OCLRDATA_") Then
astrDataSplit = regex_exec(world.GetVariable(strVarName), "([[A-Za-z]+]) (\- [A-Z]{2} [A-Za-z]+ \-) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) ([SDFJMm]{0,4})")
OtherProcessSub astrDataSplit(0), astrDataSplit(1), CSng(astrDataSplit(2)), CSng(astrDataSplit(3)), CSng(astrDataSplit(4)), CSng(astrDataSplit(5)), CSng(astrDataSplit(6)), CSng(astrDataSplit(7)), astrDataSplit(8)
World.note "[" & astrDataSplit(0) & "] - " & astrDataSplit(1) & " - x: " & astrDataSplit(2) & " y: " & astrDataSplit(3) & " z: " & astrDataSplit(4) & " Range: " & astrDataSplit(5) & " Speed: " & astrDataSplit(6) & " Head: " & astrDataSplit(7) & " Status: " & astrDataSplit(8)
End If
Next
End Sub
it parses lines of saved Variables in mushclient. but for some reason it is only displaying "Contact Information" and not any of the saved data.. here are some example lines of data that i have:
[CW] - SR Shrike - 5 5 0 3.8 0.0 0 S
[fd] - SR Stinger - 5 5 0 3.8 0.0 0 S
[JH] - DO Mammoth - 177 238 1 24.4 0.0 240
[YG] - SS Mammoth - 131 216 0 26.3 0.0 240
Can you show us the relevant variables? Select them in the variables configuration window, click the Copy button and paste the results here.
You would have to do that one at a time. Otherwise edit the world file, find the <variables> section and copy the relevant lines.
Or, more easily, when editing the variables in the configuration window, click the "save" button - that will save the lot to a text file. Edit that, and copy and paste the <variable name="blah> lines into your message.
However, leaving that aside, I would be interested to see what the array of variables returned.
Perhaps put into your loop a couple of displays, like this:
For Each strVarName In astrVarNames
world.note "Got variable: " & strVarName
If (Left(strVarName, 9) = "OCLRDATA_") Then
world.note "Variable prefix matched."
so I decided to try a few things I tried using UCase(Left(strVarName, 9)) and that just spit out an error in a completely unrelated part of the script.. which is confusing, and then I tried making OCLRDATA_ into oclrdata_ and that did the same thing
I figured it'd probly pop the same error message but it's wierd it's giving me an error in a Subroutine that isn't even called by either of the subroutines I'm using.
Taking your script that used to work (apart from the lack of displays) and changing the string literal to lower case certainly should not introduce errors elsewhere. Are you sure you didn't accidentally change something else?
Description: Invalid procedure call or argument
Line in error:
Called by: Immediate execution
the error is inside just a bunch of Cases...
This is basically all it contains:
Function ClassifyWeapon(WeaponName)
Select Case WeaponName
Case "CoolantGun"
ClassifyWeapon = "CG"
Case "AcidThrower"
ClassifyWeapon = "AT"
Case "SmallLaser"
ClassifyWeapon = "SL"
End Select
End Function
There are a bunch more Cases but I dont wanna post ehm all cause it'd be really long.
That is weird. I can't really help with that. Your original problem was that the word you were matching on should be in lower case, however why VBscript won't accept that I can't say.
Okay It IS going into the if statement, and it is displaying Variable prefix matched but then it pumps out the error when it attempts to set the variable equal to the regex_exec.. which does this:
Function regex_exec(ByVal strMatch, ByVal strRegex)
Dim regEx, Matches, Match
Set regEx = New RegExp
regEx.Pattern = strMatch
Set Matches = regEx.Execute(strRegex)
Set Match = Matches(0)
Set regEx = Nothing
Set Matches = Nothing
Set regex_exec = Match.SubMatches
Set Match = Nothing
Set strMatch = Nothing
Set strRegex = Nothing
End Function
any new ideas? I kinda didn't write half of this script so it's kidna hard for me to figure out what it all does sometimes.