Script Functions

Script function names are not case sensitive. Empty lines can be used. Comment lines must start with a # in the first position. The script file will terminate if an error has occurred. The line number where it was detected will be displayed on the status line. If the script terminates normally the text Script file closed will be displayed on the status line. The upper left corner of the view has the row and column value 1.
  
Name Description
TypeString It will type the string parameter into the screen, starting from the current cursor position. If the current input field length is less than the string length, the rest of the string will continue in the next input field. Script parameters from the command line can also be used. TypeString ("This is a text string") or TypeString ("$SP3")
FunctionKeyIt will type a function key at current cursor position. Function key names available: ENTER, TAB, BACKTAB, HOME, UP, DOWN, LEFT, RIGHT, DELETE, NEWLINE, BACKSPACE, ERASETOEOF, ERASEFIELD, ERASEINPUT, ATTENTION, SYSREQ, CLEAR, INSERT, DUP, FMARK, RESET, PA1, PA2, PA3, PF1, PF2, PF3, PF4, PF5, PF6, PF7, PF8, PF9, PF10, PF11, PF12, PF13, PF14, PF15, PF16, PF17, PF18, PF19, PF20, PF21, PF22, PF23, PF24, HELP, FIELDEXIT, ROLLUP or ROLLDOWN. FunctionKey (CLEAR)
TypeInputIt will popup an input dialog box with an information text according to the string parameter. The user input from the dialog box will be handled by the TypeString function. TypeInput ("Please type your password")
WaitForIt will suspend the script until the event parameter has occurred. Events available: CONNECT (No wait if connected, else wait until connected), UNLOCK (Keyboard reset/unlock by host system), SECURE_CONNECTION (Wait until the secure connection (SSH/SSL) has been established), KEYBOARD (Any keyboard input). WaitFor (UNLOCK)
WaitForTextIt will suspend the script until the text string parameter has been found somewhere on the screen. The text is case sensitive. WaitForText ("User name:")
WaitForTimerIt will suspend the script for some milliseconds. If no system timer is available this function will terminate the script. WaitForTimer (3500)
SetCancelTimerIt can be used to set a timer to stop a script, which is in some wait state. The parameter is the number of milli seconds until it will close the script. The script will continue with the next script function after it has been set. SetCancelTimer (60000)
WaitForCursorPosIt will suspend the script until the cursor is in an exact screen position. The first parameter is the row position and the second parameter is the column position. The first screen position is row 1 and column 1. WaitForCursorPos (20, 34)
WaitForItemsCursorPosIt will suspend the script until the cursor is in an exact screen position. The first parameter is a number item for the row position and the second parameter is a number item for the column position. The first screen position is row 1 and column 1. WaitForItemsCursorPos (RITEM, CITEM)
NoUserInputIt will return TRUE if no input has been provided from TypeInput. Can be used with the script if test. NoUserInput ()
TypeHiddenInputIt will popup an input dialog box with an input field for password input. The user input from the dialog box will be handled by the TypeString function. TypeHiddenInput ("Please type your password")
GetNewPasswordIt will popup an input dialog box with three input fields for password input. One for the current password and two for the new password (one is for confirmation). The current password and the new password will be stored in the fixed string variables CURRENT_PWD and NEW_PWD. The string variables can be used with script function TypeStringItem, like TypeStringItem (NEW_PWD). GetNewPassword ()
OpenSessionIt will open and replace current session with the new session, if the current session is connected it will be disconnected. All session setup parameters will be replaced. The script file will continue with the next script function. OpenSession ("host.nmt")
LoadSessionIt will load and replace current session with the new session, if the current session is connected it will be disconnected. All session setup parameters will be replaced. The script file will continue with the next script function, but the connection will not be opened. The next function could be ConnectHost. LoadSession ("host.nmt")
SaveSessionIt will save current session setup to a new session file or the current session file name. SaveSession ("host.nmt") or SaveSession ()
TerminateInstanceDisconnect (if connected) and close current terminal instance. TerminateInstance ()
OpenPrintSessionA new instance of NMP will be started with the print session file as command line parameter. OpenPrintSession ("hprint.nmp")
ConnectHostIt will disconnect current connection and start a new connection. Host name as parameter. No other session setup parameters will be changed. ConnectHost ("main.frame.com")
StartScriptClose current script at this position and start a new script. Default script file type is SRL (Script Recording Language). StartScript ("cics.srl")
StartApplicationIt will start a Windows Application. Include any parameters to the application after the application name. The script will terminate if the application has not been started successfully. StartApplication ("NOTEPAD hostcap.txt") or StartApplication (""C:\Program Files\nmt\nmt.exe" "C:\Program Files\nmt\tso.nmt""). Notice the double exclamation marks. Or just StartApplication (""C:\Program Files\nmt\tso.nmt"")
SetModelTypeSet model type. No connection must have been established. SetModelType (3)
SetExtendedModeSet extended mode, TRUE or FALSE. No connection must have been established. SetExtendedMode (TRUE)
SetTelnetPortSet telnet port. No connection must have been established. SetTelnetPort (1023)
SetLuNameSet LU name. No connection must have been established. SetLuName ("XYZNN")
SetAnswerbackSet answer back text for the current session. It must be called just after the OpenSession function or to configure a new session. SetAnswerback ("nexus")
DisconnectDisconnect current session if connected. No session setup parameters will be changed. Disconnect ()
IsConnectedReturns TRUE or FALSE. IsConnected ()
StartCaptureOpen a file for screen image capture. StartCapture ("hcap.txt")
StopCaptureDisable and close current capture file. StopCapture ()
SetAutoCaptureEnable or disable auto capture on attention keys - TRUE or FALSE. SetAutoCapture (TRUE)
ReceiveHostFileTransfer host file to PC in ascii CR LF mode. Two parameters: Local file name and host file name. ReceiveHostFile ("C:\temp\info.txt", "hostfn")
ReceiveBinHostFileTransfer host file to PC in binary mode. Two parameters: Local file name and host file name. ReceiveBinHostFile ("C:\temp\info.txt", "hostfn")
SendLocalFileTransfer local file to host in ascii CR LF mode. Two parameters: Local file name and host file name. SendLocalFile ("C:\temp\info.txt", "hostfn")
SendBinLocalFileTransfer local file to host in binary mode. Two parameters: Local file name and host file name. SendBinLocalFile ("C:\temp\info.txt", "hostfn")
CaptureImageCapture current screen image to file or scroll back buffer. If the file has not been opened, a file open dialog box will be opened. CaptureImage ()
TextInImageTest if a text sequence is in the current screen image. It can be used with the While/EndDo / If/EndIf block. TextInImage ("MORE INFO")
NoTextInImageTest if a text sequence is NOT in the current screen image. It can be used with the While/EndDo / If/EndIf block. NoTextInImage ("END OF DATA")
StringItemInImageTest if a string item is in the current screen image. It can be used with the While/EndDo / If/EndIf block. StringItemInImage (SITEM)
PopUpMsgDisplay a popup message. PopUpMsg ("Remember to ... .. .") or PopUpMsg (TITEM)
MsgBeepA short beep message. MsgBeep ()
StatusLineTextPut a short text on the status line. StatusLineText ("Wait for input")
MinimizeMinimize window into an icon. Minimize ()
RestoreRestore window size and position. Restore ()
SttyErase_BackspaceSend/type "stty erase BS". SttyErase_Backspace ()
SttyErase_DeleteSend/type "stty erase DEL". SttyErase_Delete ()
SttyRowsSend/type "stty number of rows". SttyRows ()
SetLabelSet a script label, which can be used by the GoToLabel script function. SetLabel ("GOTO_ABC")
GoToLabelJump or go to a script label. A "go to label" must be defined within the end of the script file. GoToLabel ("GOTO_ABC")
SetPrintBufferSet the number of print images (1 | 2 | 3). It can be used to print one, two or three images on one page. SetPrintBuffer (3)
PrintTextFilePrint a text file. It will be formatted according to the print setup. PrintTextFile ("Output.txt")
PrintDataFilePrint a text/data file. It will be sent directly to the printer. PrintDataFile ("Output.txt")
OpenPrintFileOpen a file, which screen images will be written to on "Print Screen". OpenPrintFile ("Output.txt")
ClosePrintFileClose an opened print file. OpenPrintFile ()
PrintImagePrint current screen images to a printer or to a file (if a print file has been opened). PrintImage ()
SetLinesPerPageSet number of lines on each page printed. SetLinesPerPage (72)
SetPrintFontHeightSet print font height. SetPrintFontHeight (188)
TypeHexStringType a byte sequence, which is set as a hexadecimal sequence. TypeHexString ("1B4F50")
SendHexStringSend a byte sequence (directly), which is set as a hexadecimal sequence. SendHexString ("1B4F50")
SendStringWill send the string directly to the connected server without any local emulation SendString ("Text string")
DefaultPrinterSet default printer (TRUE). If FALSE, then each print job will open the Printer Dialog. DefaultPrinter (FALSE)
NumberItemAllocate a number variable. It will be set to zero if no extra parameters are added. NumberItem (NCOUNT) or NumberItem (NCOUNT, 10)
StringItemAllocate a string or text variable. It will be set empty if no extra parameters are added. StringItem (SITEM) or StringItem (SITEM, "END OF PAGE")
SetNumberItemSet a new value for allocated number variable. SetNumberItem (NCOUNT, 100)
SetStringItemSet a new text value for a allocated string variable. The first parameter is the destination and the second parameter the source. SetStringItem (SITEM, "END OF PAGE")
CopyStringItemCopy the content of the second string item into the first string item. CopyStringItem (SITEM, TITEM) or CopyStringItem (SITEM, TEXT_ITEM)
AppendStringItemAppend the content of the second string after the first string item. AppendStringItem (SITEM, TITEM) or AppendStringItem (SITEM, TEXT_ITEM)
TrimItemSpaceClears all leading and termination spaces. TrimItemSpace (SITEM)
TrimItemLeftClears all leading space characters. TrimItemLeft (SITEM)
TrimItemRightClears all termination space characters. TrimItemRight (SITEM)
GetItemLengthCopy the string item length of the second parameter into the number value of the first parameter. GetItemLength (NCOUNT, SITEM)
CopyNumberItemCopy the content of the second number item into the first number item. CopyNumberItem (NCOUNT, ROW)
IncNumberItemIncrement the value for a allocated number varaible with 1. IncNumberItem (NCOUNT)
DecNumberItemDecrement the value for a allocated number varaible with 1. DecNumberItem (NCOUNT)
NumberItemLessThanTrue if the allocated number varaible is less than the second parameter provided. NumberItemLessThan (NCOUNT, 50) or NumberItemLessThan (NCOUNT, ROW)
NumberItemGreaterThanTrue if the allocated number varaible is greater than the second parameter provided. NumberItemGreaterThan (NCOUNT, 10) or NumberItemGreaterThan (NCOUNT, ROW)
NumberItemEqualToTrue if the allocated number varaible is equal to the second parameter provided. NumberItemEqualTo (NCOUNT, 30) or NumberItemEqualTo (NCOUNT, ROW)
CopyImageToClipboardCopy text (from row/column and number of bytes) to the clipboard. CopyImageToClipboard (10, 12, 16) or CopyImageToClipboard (RNO, CNO, NCOUNT)
PasteFromClipboardType the text from the clipboard. PasteFromClipboard ()
TypeStringItemType the string variable value into the current image cursor position. TypeStringItem (SITEM)
TypeVariableCan be used to type both string and number variables. TypeVariable (SITEM) or TypeVariable (NCOUNT)
StringItemContainsTextTrue if the string variable value contains the text. StringItemContainsText (SITEM, "abc")
StringItemSwapTextSwap some part (the second parameter) of the string variable value with an other string text (the last parameter). StringItemSwapText (SITEM, "abc", "xyz")
CopyImagetoStringItemSet the allocated string variable value to the content of the current image row, column and length. First image row and column is 1. CopyImageToStringItem (SITEM, 10, 16, 12) or CopyImageToStringItem (SITEM, RITEM, CITEM, LITEM)
StringItemsEqualTrue if the two string variables are equal. StringItemsEqual (SITEM, TITEM)
StringItemsNotEqualTrue if the two string variables are not equal. StringItemsNotEqual (SITEM, TITEM)
StringItemEqualTextTrue if the string variable is equal to the text parameter. StringItemEqualText (SITEM, "PRESS ENTER")
StringItemNotEqualTextTrue if the string variable is not equal to the text parameter. StringItemNotEqualText (SITEM, "PRESS ENTER")
SetFileTransferAppendSelect append mode file transfer (TRUE/FALSE). If TRUE, then each new file transfer will append to an existing file. SetFileTransferAppend (FALSE)
SetReceiveParametersSet extra receive file parameters, which will be appended to the default parameters. SetReceiveParameters ("abc")
ResetReceiveParametersClear the extra receive file parameters. ResetReceiveParameters ()
SetSendParametersSet extra send file parameters, which will be appended to the default parameters. SetSendParameters ("abc")
ResetSendParametersClear the extra send file parameters. ResetSendParameters ()
FileExistTest/check if a file exist. It returns TRUE or FALSE and can be used with the IF test. FileExist ("C:\temp\abc.txt")
RemoveFileRemove a file if it exist. RemoveFile ("C:\temp\abc.txt")
CopyImageToClipboardCopy a subset of the image to the Clipboard. Three parameters, row, column and number of bytes. First row and column start at position 1. CopyImageToClipboard (12, 48, 16)
LoadEbcdicTableLoad a new EBCDIC to ANSI/ASCII translation table (256 bytes). The new table must be loaded after the session has been loaded. Table index n is the ANSI/ASCII value of the corresponding EBCDIC character. LoadEbcdicTable ("C:\NMT\NewE_UK.tbl")
StartOpenSSLStart OpenSSL manually. It is used to start SSL after a successful connection through a proxy. The accelerator keys Alt+Shift+S can also be used. StartOpenSSL ()
OpenTextFileOpen a text file for parsing with ReadTextLine and GetNextItem. OpenTextFile ("C:\temp\abc.txt")
CloseTextFileClose the opened text file. It will also be closed when the script terminates. CloseTextFile ()
ReadTextLineRead a line from the opened text file into the fixed variable TEXT_LINE. It can later be used with the script function TypeStringItem (TEXT_LINE). It returns FALSE at end of file.ReadTextLine ()
GetNextItemGets the next text item from the fixed variable TEXT_LINE. The text string will be stored in the fixed variable TEXT_ITEM. It can later be used with the script function TypeStringItem (TEXT_ITEM). The default text separator is ",\t\n", but it can be changed with the script function SetTextToken. It returns FALSE at end of line.GetNextItem ()
SetTextTokenSet the text item separator for the GetNextItem function. SetTextToken (" ;\t")
AcceptEmptyItemsGetNextItem will default not return empty items, but if AcceptEmptyItems is called with the parameter TRUE, then also empty items will be returned. AcceptEmptyItems (TRUE)
IsStringItemEmptyIt can be used to test if a string variable is empty. IsStringItemEmpty (TEXT_ITEM)
IsStringItemNotEmptyIt can be used to test if a string variable is not empty. IsStringItemNotEmpty (SITEM)
WaitForStringStop the script execution until the string variable is detected in the screen image. It can be used after a TypeStringItem to verify that is has been sent and received by the remote server (vt/ansi echo mode). WaitForString (SITEM)
SetCursorPosSet cursor position for a 3270 or 5250 terminal session. The first parameter is row and the second is column. Upper left corner is row 1 and column 1. SetCursorPos (12, 52)
SetRowColumnSet cursor position for a 3270 or 5250 terminal session. The first parameter is a number item for the row and the second is a number item for the column. Upper left corner is row 1 and column 1. SetCursorPos (RITEM, CITEM)
GetCursorPosCopy the current cursor position into two number items. The first parameter is for the row and the second for the column. Set cursor position for a 3270 or 5250 terminal session. The first parameter is a number item for the row and the second is a number item for the column. GetCursorPos (RITEM, CITEM)
GetViewSizeCopy the current terminal view size into two number items. The parameter is for the row and the second for the column. Set cursor position for a 3270 or 5250 terminal session. The first parameter is a number item for the row and the second is a number item for the column. GetViewSize (RITEM, CITEM)
OpenOutputFileOpen a text file for writing. Up to ten files can be opened at the same time. The first parameter is the file id (0|1|2|3|4|5|6|7|8|9) and the next parameter is the file name to be opened. If the file exist, then the output will be appended, else it will create a new file. OpenOutputFile (0, "C:\temp\abc.log")
CloseOutputFileClosed an opened file. The file id (0|1|2|3|4|5|6|7|8|9) is the only needed parameter. CloseOutputFile (0)
WriteItemToFileWrite a text or number variable/item to an opened file. The first parameter is the file id and the next parameter is the string or number item. WriteItemToFile (0, TEXT_ITEM)
WriteStringToFileWrite a text string to an opened file. The first parameter is the file id and the next parameter is the string. Both WriteItemToFile and WriteStringToFile will remove leading and terminating spaces. WriteStringToFile (0, "Have a nice day")
AppendNewLineToFileWrite a new line to an opened file. The only parameter needed is the file id. AppendNewLineToFile (0)
AppendTabToFileWrite a tab character to an opened file. The only parameter needed is the file id. AppendTabToFile (0)
FlushOutputFileFlush an opened file. The only parameter needed is the file id. FlushOutputFile (0)
AppendTsToFileAppend a time stamp to an opened file. The only parameter needed is the file id. AppendTsToFile (0)
SetCloseOnDisconnectSet close on disconnect (TRUE/FALSE). SetCloseOnDisconnect (FALSE)
SetShortIdSet short HLLAPI id (a single character). SetShortId ("A")
SetLongIdSet long HLLAPI id (max 8 characters). SetLongId ("Nexus")
ClearImageClear the screen image for a vt/ansi session. The cursor will be moved to the first position (1/1). ClearImage ()
SetTsFormatSet time stamp format. The formatting codes are listed below:
%a Abbreviated weekday name
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Date and time representation appropriate for locale
%d Day of month as decimal number (01 - 31)
%H Hour in 24-hour format (00 - 23)
%I Hour in 12-hour format (01 - 12)
%j Day of year as decimal number (001 - 366)
%m Month as decimal number (01 - 12)
%M Minute as decimal number (00 - 59)
%p Current locale’s A.M./P.M. indicator for 12-hour clock
%S Second as decimal number (00 - 59)
%U Week of year as decimal number, with Sunday as first day of week (00 - 53)
%w Weekday as decimal number (0 - 6; Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 - 53)
%x Date representation for current locale
%X Time representation for current locale
%y Year without century, as decimal number (00 - 99)
%Y Year with century, as decimal number
%z Time-zone name
%Z Time-zone name abbreviation
%% Percent sign

The # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows.
%#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z, %#% # flag is ignored.
%#c Long date and time representation, appropriate for current locale. For example: Tuesday, March 14, 1995, 12:41:29.
%#c Long date and time representation, appropriate for current locale. For example: Tuesday, March 14, 1995, 12:41:29.
%#x Long date representation, appropriate to current locale. For example: Tuesday, March 14, 1995.
%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y Remove leading zeros (if any).

SetTsFormat ("%B %d, %Y %H:%M:%S")
KermitDownloadDownload a remote file with the Kermit protocol. Remote file name as parameter. KermitDownload ("xyz.txt")
KermitUploadUpload a local file with the Kermit protocol to the remote server. Local file name as parameter. KermitUpload ("C:\temp\abc.txt")
PopUpEncStringEncrypted the input text and popup the result in a message box. PopUpEncString ("password")
TypeEncStringWill decrypt the hexadecimal input text and send it to the connected host. TypeEncString ("CAC4CFDBE9C374")
A simple logon script.

OpenSession ("abc.nmt")
WaitFor (CONNECT)
WaitFor (UNLOCK)
# You should always add these two script commands after OpenSession
WaitForText ("User")
# The script engine will block until the text "User" is found in the image.
# Other keyboard and network operations are not blocked.
TypeString ("hans")
FunctionKey (TAB)
# Cursor moved to the next input field
TypeString ("erik")
FunctionKey (ENTER)
# Enter and wait for unlock and end of script.
WaitFor (UNLOCK)
While/If-blocks can be nested. And several If-blocks can be used in a While-block and several While-blocks can be used in an If-block.

While TextInImage ("MORE INFO")
  # Other script functions
  CaptureImage ()

  FunctionKey (ENTER)
  WaitFor (UNLOCK)
  # It's very import to add "flow-control" statements to a script file.
  # The enter key will generate a data packet sent to the connected server.
  # If the waitfor statement (script function) is not included,
  # then the script will continue at once at the top of the while loop.
EndDo

If TextInImage ("END OF TEXT")
  StopCapture ()
  StartApplication ("notepad cap.txt")
EndIf

NumberItem (ABC)
# Number variable ABC set equal to zero
While NumberItemLessThan (ABC, 10)
  # Other script functions
  IncNumberItem (ABC)
EndDo
SetLabel and GoToLabel can be used to build while-loops within an other while loop like:

OpenTextFile ("C:\temp.txt")
# The text file is opened at this point, else the script would have be terminated
# Default text item separator
While ReadTextLine ()
  SetLabel ("Next_Item")
  # The script file is preprocessed, so this statement will not be added for each iteration
  # GotoLabel statement can even be included before the corresponding SetLabel
  If GetNextItem ()
    # Next item successfully stored, so
    # do what you want with the text stored in TEXT_ITEM
    gotolabel ("Next_Item")
  EndIf
  # At this point the while loop will continue with the next line
EndDo
# All lines has been parsed, so close the text file
CloseTextFile ()
An other example:

# Session connected and in the correct screen view.
OpenTextFile ("C:\temp\inp.txt")
OpenOutputFile (0, "C:\temp\outp.txt")
SetTextToken (" ,")
NumberItem (NC)
StringItem (ITAG)
# The number variable NC is set equal to zero
While ReadTextLine ()
  # The indentation is not needed   GetNextItem ()
  # Drop the first item
  GetNextItem ()
  TypeStringItem (TEXT_ITEM)
  CopyImagetoStringItem (ITAG, 23, 2, 8)

  FunctionKey (ENTER)
  WaitFor (UNLOCK)
  WriteItemToFile (0, TEXT_ITEM)
  AppendTabToFile (0)
  WriteItemToFile (0, ITAG)
  AppendTabToFile (0)
  WriteItemToFile (0, NC)
  AppendNewLineToFile (0)
  IncNumberItem (NC)
EndDo
CloseTextFile ()
CloseOutputFile (0)
# This script reads the screen image, one character at the time and writes it to a file.
# The text file is afterwards opened with notepad. It demonstrates how to write "goto loops" within an while loop.
NumberItem (ROWS)
NumberItem (COLUMNS)
NumberItem (RC, 1)
NumberItem (CC, 1) NumberItem (LENGTH, 1)

StringItem (ONECHAR)

GetViewSize (ROWS, COLUMNS)
IncNumberItem (ROWS)
IncNumberItem (COLUMNS)

# TypeVariable (ROWS)
# TypeVariable (COLUMNS)

If FileExist ("C:\temp\view.txt")
   RemoveFile ("C:\temp\view.txt")
EndIf

OpenOutputFile (0, "C:\temp\view.txt")

While NumberItemLessThan (RC, ROWS)
   SetLabel (CURRENT_ROW)
   If NumberItemLessThan (CC, COLUMNS)
     CopyImageToStringItem (ONECHAR, RC, CC, LENGTH)
     WriteItemToFile (0, ONECHAR)
     IncNumberItem (CC)
     GotoLabel (CURRENT_ROW)
   EndIf

   IncNumberItem (RC)
   SetNumberItem (CC, 1)
   AppendNewLineToFile (0)
EndDo

CloseOutputFile (0)
# TypeString ("Open view.txt")
StartApplication ("Notepad C:\temp\view.txt")
One single script file can start several nexus session (and other tasks):
# Start cics session A (in a new instance of Nexus Terminal)
StartApplication (""C:\Program Files\nmt\nmt.exe" "C:\Program Files\nmt\cics_a.nmt"")
# Start cics session B with the script file cics_b.srl
StartApplication (""C:\Program Files\nmt\nmt.exe" "C:\Program Files\nmt\cics_b.srl"")
# Start the tso session
StartApplication (""C:\Program Files\nmt\nmt.exe" "C:\Program Files\nmt\tso.nmt"")
# This instance of Nexus Terminal will continue with cics session C
OpenSession (""C:\Program Files\nmt\cics_c.nmt"")