Power Scripting Language (PSL)

 

PowerTerm Script Language Overview

The PowerTerm Script Language (PSL) is intended for users who have programming skills. The language is based on C and UNIX shell.

You can easily create one of the scripts offered in the session command and start a communication session automatically, as you activate PowerTerm.

 

Activating Script Files From the Host

A host application may activate a script file or script commands via special escape sequences.

Escape Sequences for VT

Activating a script file by the name Script-Name:

ESCP$sScript-NameESC \

Example: activating the message.psl script:

ESCP$smessage.pslESC\

Note

§         ESC is the ASCII 27 code.

Activating script commands Script-Commands:

ESCP$tScript-CommandsESC \

Example: activating the "message testing ; send end" commands:

ESCP$tmessage testing ; send endESC\

Escape Sequences for DG

Activating a script file by the name Script-Name:

ESCWsScript-Name000

Note

§         ESC is the ASCII 30 code, 000 is the ASCII 0 code.

Activating script commands Script-Commands:

ESCWtScript-Commands000

PSL Syntax

A command consists of one or more fields separated by spaces or tabs. The first field is the name of a command, which may be either a built-in command or a procedure consisting of a sequence of PSL commands. Newline characters are used as command separators, and semicolons may be used to separate commands on the same line. Each PSL command returns either a string result, or an empty string.

PSL has four additional syntactic constructs:

·         Curly braces { }

·         Square brackets [ ]

·         Dollar sign $

·         Backslash  \

Curly Braces

Curly braces are used to group complex arguments; they act as nestable quote characters. If the first character of an argument is an open brace, then the argument is not terminated by white space. Instead, it is terminated by the matching close brace. The argument passed to the command consists of everything between the braces, with the enclosing braces stripped off.

For example:

host = {vms unix {aix hp sun} aos}

Variable host will receive one argument: "vms unix {aix hp sun} aos".

This particular command will set the variable host to the specified string.

If an argument is enclosed in braces, then none of the other substitutions described below is made on the argument. One of the most common uses of braces is to specify a PSL subprogram as an argument to a PSL command.

Square Brackets

Square brackets are used to invoke command substitution. If an open bracket appears in an argument, then everything from the open bracket up to the matching close bracket is treated as a command and executed recursively by PSL. The result of the command is then substituted into the argument in place of the bracketed string.

For example:

msg = [format {Data is %s bytes long} 99]

The format command does print-like formatting (from the C language) and returns the string "Data is 99 bytes long", which is then assigned to variable msg.


Dollar Sign

The dollar sign is used for variable substitution. If it appears in an argument, then the following characters are treated as a variable name; the contents of the variable are substituted into the argument in place of the dollar sign and name.

For example:

num = 99

msg = [format {Data is %s bytes long} $num]

The result is the same as the single command in the previous example.

Backslash

The backslash character may be used to insert special characters into arguments, such as curly braces or nonprinting characters.

PSL Data Types

PSL uses only one type of data: strings. All commands, arguments to commands, results returned by commands, and variable values are ASCII strings.

Although everything in PSL is a string, many commands expect their string arguments to have particular formats. There are three particularly common formats for strings:

§         Lists

§         Expressions

§         Commands

A list is just a string containing one or more fields separated by white space, similar to a command. Curly braces may be used to enclose complex list elements; these complex list elements are often lists in their own right.

For example:

{vms unix {aix hp sun} aos}

is a list with four elements, the third of which is a list with three elements.

PSL provides commands for a number of list-manipulation operations, such as creating lists, extracting elements, and computing list lengths.

The second common form for a string is a numeric expression. PSL expressions have the same operators and precedence as expressions in the C language.

The expr PSL command evaluates a string as an expression and returns the result (as a string, of course).

For example:

expr {($x < $y) || ($z != 0)}

Returns "1'' if the numeric value of variable x is less than that of variable y, or if variable z is not zero; otherwise it returns "0''. Several other commands, such as if and for, expect one or more of their arguments to be expressions.

The third common interpretation of strings is as commands (or sequences of commands). Arguments of this form are used in PSL commands that implement control structures.

For example:

  if {$x < $y} {

            swap = $x

            x = $y

            y = $swap

  }

The if command receives two arguments here, each of which is delimited by curly braces. if is a built-in command that evaluates its first argument as an expression; if the result is non-zero, if executes its second argument as a PSL command. This particular command swaps the values of the variables x and y if x is less than y.

PSL also allows users to define command procedures written in the PSL language. The proc built-in command is used to create a PSL procedure (PSLproc).

For example:

  proc factorial x {

            if {$x == 1} {return 1}

            return [expr {$x * [factorial [expr $x - 1]]}]

  }

This PSL command defines a recursive factorial procedure:

The proc command takes three arguments: a name for the new PSLproc, a list of variable names (in this case the list has only a single element, x), and a PSL command that comprises the body of the PSLproc. After this proc command has been executed, factorial may be invoked just like any other PSL command.

For example:

factorial 4

returns the string "24''.

In addition to the commands already mentioned, PSL provides commands for manipulating strings (comparison, matching, and printf/scanf-like C language operations), commands for manipulating files and file names. The built-in PSL commands provide a simple but complete programming language.

Variable Assignment

Assignments to variables follow this syntax:

varName = value

varName(index) = value

The assignment sets the value of varName to a value, creating a new variable if one does not already exist. If varName contains an open parenthesis and ends with a close parenthesis, then it refers to an array element: the characters before the first open parenthesis are the name of the array, and the characters between the parentheses are the index within the array. The index may take any value. Otherwise varName refers to a scalar variable.

If no procedure is active, then varName refers to a global variable. If a procedure is active, then varName refers to a parameter or local variable of the procedure unless the global command has been invoked to declare varName to be global.

Variable assignment returns to its value.

The following line assigns the value "green" to variable host:

host = "green"

This line assigns the value "vms" to item vax of array name:

name(vax) = "vms"

PowerTerm WebConnect logical directories enable PSL scripts/commands to specify files and folders physically located under PowerTerm WebConnect in a non-physical fashion. In certain cases the locations are run-time context dependent.

                               

Name      

Translation

Context Dependent

<user>

The user’s folder

Yes

<group>

The folder of the session’s current group.

Yes

<connections>  

The Connections folder under the DataBase folder.

No

<defaults>

The PtDefaults folder under the DataBase folder.

No

<path>

A search list of: <user>, <group>, <connections> and  <defaults>.

Yes

<local>

The install folder of the ActiveX or OCX on the client’s local machine. No translation exists for the Java client.

N/A

 

<local-setup>

When the PSL command w2h-set-local-folderw2h_set_local_folder or w2h-set-default-setup-folderw2h_set_default_folderwas used, then the <local-setup> folder is translated to the folder specified in the last call.

Otherwise, the current working folder will be used for translation.

No translation exists for the Java client.

 

N/A

<local-script>

When the PSL command w2h-set-local-folder or w2h-set-default-script-folder was used, then the <local-script> folder is translated to the folder specified in the last call. Otherwise, the current working folder will be used for translation.No translation exists for the Java client.       

N/A

<*>

The <local> or <path> logical directory.

Yes

 

The following PSL commands support logical directories:

   

open-keyboard-file

open-power-pad-file

open-setup-file

run

w2h-file-exists


 Menu Items

 

Key String

ActiveX

Java

NewTerminalSetup

+

-

OpenTerminalSetup

+

-

SaveTerminalSetup

+

-

SaveTerminalSetupAs

+

-

SaveAsIcon

+

-

OpenKeyboardFile

+

-

SaveKeyboardFile

+

-

OpenPowerPadFile

+

+

SavePowerPadFile

+

+

PrintScreen

+

+

PrintSetup

+

+

ToggleAutoPrint

+

+

StartAutoPrint

+

+

FormFeed

+

-

LineFeed

+

-

NewTerminalWindow

+

+

Exit

+

+

SelectScreen

+

+

ClearScreen

+

+

ReverseScreen

+

+

SelectHistory

+

-

ClearHistory

+

-

Copy

+

-

Paste

+

+

Cut

+

-

CopyToFile

+

-

AutomaticCopy

+

-

PowerTermFonts

+

-

SystemFonts

+

-

TerminalSetup

+

+

General

+

-

Reset

+

-

OnLine

+

+

HoldScreen

+

+

Connect

+

+

Disconnect

+

+

ResetCommunication

+

-

ModemSetup

+

-

FileTransferSetup

+

-

SendFile

+

-

SendKermit

+

-

SendZmodem

+

-

SendINDFILE

+

-

ReceiveFile

+

-

ReceiveKermit

+

-

ReceiveZmodem

+

-

ReceiveINDFILE

+

-

RunFTP

+

-

Dial

+

-

Break

+

-

SetDTR

+

-

ClearDTR

+

-

SetRTS

+

-

ClearRTS

+

-

KeyboardMap

+

+

PowerPadSetup

+

+

ToggleTrace

+

-

StartTrace

+

+

StopTrace

+

+

InputTrace

+

-

ReceiveAsciiFile

+

-

SendAsciiFile

+

-

HideMenu

+

-

ShowMenu

+

-

HideButtons

+

-

ShowButtons

+

-

HideStatusBar

+

-

ShowStatusBar

+

-

HideToolBar

+

-

ShowToolBar

+

-

HidePowerPad

+

+

ShowPowerPad

+

+

RunScript

+

-

EditScript

+

-

ScriptCommand

+

-

ToggleScriptRecording

+

-

StartScriptRecording

+

-

StopScriptRecording

+

-

PauseScriptRecording

+

-

ActivateRecordedScript

+

-

SaveRecordedScript

+

-

Contents

+

-

About

+

+

Login

-

+

Reconnect

-

+

PrintJobList

-

+

Edit

-

+

SendMessage

-

+

Send

-

+

Cascade

-

+

TileHorizontally

-

+

TileVertically

-

+

ChangePassword

-

+

Language

-

+

TimeZoneOffset

-

+

GUIFont

-

+

EmulationWindowFont

-

+

AutoFitFont

-

+

RegularFont

-

+

BoldFont

-

+

HebrewTextReverse

-

+

UseVTKeyboardMode

-

+

RequestAdministrator'sAssistance

-

+