Help with Custom Script Engine


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Help with Custom Script Engine

  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Unhappy Help with Custom Script Engine

    Hey everyone. I have a module which parses a script and does the according actions,
    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
    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.

    -BP

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    First, get rid of all the gotos and second, get rid of the On Error Resume Next.

    What kind of parsing do you need to do to the "script" you are feeding this?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 2
    Last Post: 08-23-2005, 02:19 PM
  2. Replies: 3
    Last Post: 08-20-2002, 12:14 AM
  3. Script Engine with Database
    By Tom in forum Mobile
    Replies: 0
    Last Post: 11-15-2001, 09:24 PM
  4. PRB w/ custom form, public folder & event script
    By Jason Thorn in forum Enterprise
    Replies: 0
    Last Post: 04-02-2001, 06:09 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center