Rocket Terminal Emulator

 View Only

Running BlueZone Script Host from a Command-line

  • 1.  Running BlueZone Script Host from a Command-line

    ROCKETEER
    Posted 12-30-2020 05:58
    Edited by Tommy Hueber 12-30-2020 05:59

    This article is part of the Automation and Scripting - Did you know series
     

    Running BlueZone Script Host from a Command-line

    Did you know BlueZone comes bundled with a propriety Terminal Emulator Scripting Language, and that it also supports many other languages? Being able to automate terminal session navigation with scripts will allow you to be more productive, and multi-language support makes it easy for anyone to do. The use cases are endless: simply automate keystrokes, tedious and cumbersome processes, and avoid human error and speed up processing at the same time.

    THE POWER OF CLI

    For certain use cases it's very convenient to be able to use the command-line instead of using a graphical user interface. You can do this by invoking BlueZone Script Host from a command-line to play or edit BlueZone scripts.  Supported program switches include:
     

    /p - Play Script, follow with an optional path and filename to play a BlueZone script.

    /e - Edit Script, follow with an optional path and filename to edit a BlueZone script.

    /q - Quiet Mode, if enabled BlueZone Script Host will not display any error messages, useful for unattended use on a server.

    /a - Script arguments, any data parameters to pass to the script, see below.

    When the /p switch is specified to play a script, BlueZone Script Host will run hidden and the process will close automatically when the script completes. Also note that the full path can be omitted if the script exists in the BlueZone\Scripts folder.


    For example, to play script myScript.bbs from a command line:

    "C:\Program Files\BlueZone\8.1\Bzsh.exe" /pmyScript.bbs

     

    PASSING AND RETRIEVING SCRIPT ARGUMENTS

    You can pass script arguments to a script by including the /a switch as the last switch on the command-line, for example:

    "C:\Program Files\BlueZone\8.1\Bzsh.exe" /plogon.bbs /aRed,Green,Blue
     

    In the script, to retrieve the arguments, use the Command keyword.  You can pass multiple arguments separated by a delimiter, and in the script use the GetField method to parse the arguments, for example:

     

    Sub Main

      Dim i, index As Integer

      Dim arg As String

      Dim myArgs() As String

     

      MsgBox "The script arguments are " & Command

      If (Command <> "") Then

        Do

          arg = GetField(Command, index+1, ",")

          If (arg <> "") Then

            Redim Preserve myArgs(index+1)

            myArgs(index) = arg

            index = index + 1

          Else

            Exit Do

          End If

        Loop

      End If

     

      For i = 0 to Index-1

        MsgBox "Argument #" & i+1 & " is " & myArgs(i)

      Next i

     

    End Sub

     

    Using these techniques, BlueZone Script Host can be run from batch files, other programs, or even from other scripts.   Passing script arguments enables a script to be written to modify its behavior based on external parameters. 

    Happy scripting and please considering sharing what tasks you've been able to automate with forum members.

    ------------------------------
    Tommy Hueber
    Rocket Software
    ------------------------------