Hey everyone. I have a module which parses a script and does the according actions,
and I am experiencing problems. Whenever I run a script, it loops on the first command. I know it is to do with the goto commands. I had the same command inside itself because otherwise it says something about object variable or with block variable not set. Can anyone help me fix the code so it doesn't infinitely loop on the first command? Cheers.Code:Sub ExecuteScript(ByVal script As String) On Error Resume Next Dim LineArray, CurrentLine, LineSplit, LCommand As String, LArgs, FSO As FileSystemObject LineArray = Split(script, ";;") For x = LBound(LineArray) To UBound(LineArray) line: CurrentLine = LineArray(x) LineSplit = Split(CurrentLine, ".:", 2) LCommand = LineSplit(0) LArgs = Split(LineSplit(1), ",,") If LCase(LCommand) = "showmessage" Then MsgBox LArgs(0), vbInformation, "Script says..." If LCase(LCommand) = "map" Then modDM.MountVD LArgs(0) + ":", LArgs(1) If LCase(LCommand) = "unmap" Then modDM.UnMountVirtualDrive LArgs(0) + ":" If LCase(LCommand) = "write" Then writes LArgs(0), LArgs(1) If LCase(LCommand) = "append" Then appends LArgs(0), LArgs(1) If LCase(LCommand) = "copyfile" Then FileCopy LArgs(0), LArgs(1) If LCase(LCommand) = "delete" Then Kill LArgs(0) If LCase(LCommand) = "gotoiffileexist" And FSO.FileExists(LArgs(0)) Then x = CLng(LArgs(1)) If LCase(LCommand) = "gotoiffileexist" And FSO.FileExists(LArgs(0)) Then GoTo line End If If LCase(LCommand) = "gotoiffolderexist" And FSO.FolderExists(LArgs(0)) Then x = CLng(LArgs(1)) If LCase(LCommand) = "gotoiffolderexist" And FSO.FolderExists(LArgs(0)) Then GoTo line End If If LCase(LCommand) = "goto" Then x = CLng(LArgs(1)) If LCase(LCommand) = "goto" Then GoTo line End If Next x End Sub
-BP


Reply With Quote



Bookmarks