Script Command Line Arguments

Return to Introduction  Previous page  Next page

It is possible to pass arguments to a TN3270 Plus script.  Arguments are passed on the command line following the full path to the script file. Arguments are separated by spaces.  If any of the arguments contain spaces they must be enclosed in double quotes.

Within the script  the following built-in variables hold the command line arguments.

 

$ARGC

count of arguments on the command line.

$ARG0

full path of the script file from the command line.

$ARG1, $ARG2...

arguments from the command line.

The following script displays the command line arguments passed by the caller.

' DisplayArguments.txt

' Sample script to display arguments passed on the script command line.

MsgBox("Argument Count =  " & $ARGC & $CRLF)

MsgBox("Script Path  =  " & $ARG0 & $CRLF)

$Count = 1

Loop:

If $Count < $ARGC then

 MsgBox("$ARG" & $Count & " = " & $ARG$Count)

 $Count = $Count + 1

else

 Exit

End If

GoTo Loop:

 

You cannot pass arguments via the "Host, Run Script" command but you can specify them on the startup script file (Setup, Host, Script File).

Calling a TN3270 Plus Script from Another TN3270 Plus Script

The following is an example of calling a TN3270 Plus script with command line arguments from another script. The following sample script calls the DisplayArguments.txt script above

'PassArguments Script

'

include("c:\Scripts\DisplayArguments.txt ONE TWO THREE")

exit

 

Calling a TN3270 Plus Script from a Windows VB Script

Here is an example of calling a TN3270 Plus script  with command line arguments from a VB Script:

' Call a TN3270 Plus Script from a Windows VB Script

' Language: VBScript using the Windows Script Host

' When the objShell.Run command parameter contains double quotes within the parameter,

' substitute each double quote in the parameter with two double quotes.

dim objShell

set objShell = WScript.CreateObject("WScript.Shell")

objShell.Run """c:\Program Files (x86)\SDI\TN3270 Plus\tnrun.exe""" _

       & "mainframe script c:\scripts\DisplayArguments.txt ONE TWO THREE"

 


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.