home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
pibterm
/
pibt41d2.arc
/
PT41SCRI.DOC
< prev
Wrap
Text File
|
1988-03-04
|
285KB
|
5,487 lines
+=================================================+ +=================================================+
| PibTerm Script Language Reference Guide | | PibTerm Script Language Reference Guide |
+=================================================+ +=================================================+
Copyright (c) February, 1988 by Philip R. Burns Copyright (c) February, 1988 by Philip R. Burns
Using Script Files .................................... 1 Using Script Files .................................... 1
Compatibility With Old Scripts .................... 1
Executing a Script File ............................... 1 Executing a Script File ............................... 1
From the PibTerm command line ..................... 1
From <ALT>G ....................................... 2
User-defined command .............................. 2
Compiling Scripts ................................. 2
Limitations on Script Size ........................ 2
Script Library PIBTERM.SCL ........................ 2
Search Order For Scripts ...................... 3
Terminating Execution Of A Script ................. 4
Automatic Script Generation -- The Learn Facility . 4
Script File Commands .................................. 4 Script File Commands .................................. 4
General Syntax of Script Commands ................. 9
Script Variable Names ............................. 9
Declaring variables ........................... 10
Saving variable values after script ends ...... 10
Detailed Description of Script Commands ............... 11 Detailed Description of Script Commands ............... 11
AddCommand -- Add User-Defined Command ............ 11
Addlf -- Add Line Feeds ........................... 14
Alarm -- Issues Five Beeps ........................ 14
Break -- Send Break ............................... 14
Call -- Call Internal Script Procedure ............ 14
Capture -- Capture Session To Disk ................ 14
Case -- Case Selector For DoCase .................. 15
ChDir -- Change Current Directory or Drive ........ 15
Clear -- Clear Screen ............................. 15
Close -- Close File ............................... 16
ClrEol -- Clear Display To End Of Line ............ 16
ComDrain -- Drain Serial Port Output Buffer ....... 16
ComFlush -- Flush Serial Port Buffers ............. 16
CopyFile -- Copy File ............................. 17
Delay -- Delay Execution For Specified Interval ... 17
DelLine -- Delete Current Line On Screen .......... 18
Dial --- Dial A Number ............................ 18
DirFirst -- Find First Matching File .............. 18
DirNext -- Find Next Matching File ................ 20
DoCase -- Do Case Statement ....................... 22
Dos -- Execute DOS Command ........................ 23
Echo --- Toggle Local Echo ........................ 24
EditFile -- Invoke File Editor .................... 24
Else -- Part Of IF Statement ...................... 24
EndCase -- Ends Case Block ........................ 25
EndDoCase -- Ends DoCase Statement ................ 25
EndIf --- Ends An IF Statement .................... 25
EndProc -- Ends a Script Procedure ................ 25
EndWhile -- Ends a WHILE block .................... 25
EraseFile -- Erase (Delete) A File ................ 25
Execute -- Execute One Script From Another ........ 25
Exit -- Terminate Script Execution ................ 27
ExitAll -- Exit Nested Scripts .................... 27
For -- Start FOR Loop ............................. 28
FreeSpace -- Find Free Space On Drive ............. 28
GetDir -- Get Current Directory And Drive ......... 29
GetParam -- Get Value of PibTerm Parameter ........ 29
GetVar -- Get Value of Script Variable ............ 30
GoToXY -- Move To Specified Screen Position ....... 31
Hangup -- Hang Up The Phone ....................... 32
Host -- Enter Host Mode ........................... 32
If -- Conditionally Execute Statements ............ 32
Conditions allowed in IF statements ........... 32
Import -- Import Variable To Execute Script ....... 33
Input -- Get Input From Keyboard .................. 34
InsLine -- Insert Line At Cursor .................. 35
Key -- Set Function Key Values .................... 35
KeyDef -- Define Function Key Value ............... 36
KeyFlush -- Flush KeyBoard ........................ 37
KeySend -- Send Function Key Value To Remote ...... 37
Log -- Toggle Printer Logging ..................... 38
Menu -- Display Pop-Up Menu ....................... 38
Message -- Display Message On Screen .............. 39
Mute -- Toggle Mute Mode .......................... 39
Open -- Open File ................................. 39
Param -- Set Program Parameter .................... 40
PrintFile -- Print A FIle ......................... 41
Procedure -- Define Script Procedure .............. 41
Quit -- Quit PibTerm execution .................... 44
Read -- Read Character From A File ................ 44
Readln -- Read Line From File ..................... 45
Receive -- Receive File From Remote System ........ 46
Redial -- Redial Last Number Dialed ............... 48
Repeat -- Repeat Block Of Statements .............. 48
Reset -- Reset Script Execution To Start Of Script 49
RInput -- Receive Input From Remote System ........ 49
ScreenDump -- Dump Screen To File ................. 50
Send -- Send File To Remote System ................ 50
Set -- Assign Value To Script Variable ............ 52
SetParam -- Set Value Of PibTerm Parameter ........ 55
SetVar -- Set Value of PibTerm Parameter .......... 56
SText -- Send Text To Remote System ............... 57
Suspend -- Suspend Execution Of Script ............ 57
Text -- send text to remote system ................ 58
Translate -- Read In Translate Table .............. 58
Until -- Ends Repeat Block ........................ 58
ViewFile -- Invoke File Viewer .................... 58
Wait -- Wait For Time Of Day ...................... 59
WaitCount -- Wait For Number Of Characters ........ 59
WaitList -- Wait For List Of Strings .............. 60
WaitQuiet -- Wait For Quiet Line .................. 61
WaitString -- Wait For String From Remote ......... 61
WaitTime -- Set Wait Time ......................... 62
When -- Wait For String And Respond ............... 62
WhenDrop -- Take Action On Carrier Drop ........... 63
WhereXY -- Return Current Cursor Position ......... 63
While -- Execute Statements While Condition True .. 64
Write -- Write Characters To File ................. 64
Writeln -- Write Line To File ..................... 65
WriteLog -- Write String To Log Files ............. 65
Using Script Commands in Command Line Mode ............ 65 Using Script Commands in Command Line Mode ............ 65
Command mode key definition ....................... 65
Script Commands Legal In Command Line Mode ........ 66
Sample Scripts ........................................ 67 Sample Scripts ........................................ 67
CDC/NOS login script .............................. 67
VAX/VMS login script .............................. 68
IBM CMS login script .............................. 69
LUIS login script ................................. 71
OPUS login script ................................. 72
RBBS login script ................................. 73
IBBS login script ................................. 73
CompuServe login script ........................... 74
Using A Password File ............................. 75
PC Board login script using password file ......... 78
Reading A New Configuration File .................. 80
Defining Scripts For External Transfer Protocols ...... 81 Defining Scripts For External Transfer Protocols ...... 81
SENDMLIN.SCR for sending files with MegaLink ...... 84
RECMLINK.SCR for receiving files with MegaLink .... 86
SENDZMOD.SCR for sending files with Zmodem ........ 87
RECZMOD.SCR for receiving files with Zmodem ....... 89
Using Script Files Using Script Files
PibTerm provides an extensive script file facility which
allows you to create a file containing a set of instructions
for PibTerm to execute. The instructions can include dialing
up a remote system, performing file transfers, waiting for
a specific time before initiating an event, and many others.
Scripts allow PibTerm to run in unattended mode and take
advantage of off-hours rates on host computer systems.
Scripts automate such chores as logging into remote systems.
And, scripts provide you with the tools you need to
customize PibTerm by adding new commands or replacing built-
in commands with those of your own devising.
Compatibility With Old Scripts Compatibility With Old Scripts
The script language starting with PibTerm v4.0 represents a
considerable upgrade of the script language available in
previous versions. Most of the script commands have
changed, mainly to support script variables. When writing
new scripts you should use the new syntax and facilities.
However, scripts written using the old pre-version-4.0
script language SHOULD continue to work with just a few
minor changes. If an old script does not execute correctly
with PibTerm v4.0 (or a later version), try rewriting the
part of the old script that fails using the new script
syntax. Most of the incompatibilities arise because of
script variables, which are new in PibTerm v4.0, and because
of minor changes in things like file transfer protocol
abbreviations.
Executing a Script File Executing a Script File
There are three ways to execute a script file. The first is
to enter the file name of a script file on the PibTerm
command line itself at the DOS prompt:
PIBTERM /s=script.SCR
where script.SCR is the name of a script file. You need not script.SCR
explicitly give the .SCR, it is understood if no other .SCR
extension is provided.
When PibTerm begins execution, it will take its input from
the script file. You may still type keyboard entries if you
desire, and there are some script commands which explicitly
request keyboard input. This provides quite a bit of
flexibility in case something goes wrong during the
execution of a script and you are present to repair the
damage.
PibTerm Script Language Reference Guide Page 2 PibTerm Script Language Reference Guide Page 2
If no script file name appears on the PibTerm invocation,
PibTerm looks for the file PIBTERM.SCR and executes it PIBTERM.SCR
automatically if found. This is useful if you want to
execute a fixed set of commands each time you start up
PibTerm.
The second way to execute a script file is to hit <ALT>G.
You will be prompted for the name of the script file to
execute. Again, you need only provide the first part of the
file name; .SCR is understood.
If you hit the Enter key, a directory of available scripts Enter
appears. You can choose to execute one by using the arrow
keys to move to the desired script and hitting the Enter or Enter
Return key. Return
The third way to execute a script is through the use of
user-defined commands. PibTerm allows you to execute a
subset of script commands using a command-line mode. You
can also define your own commands as extensions to the
script language; these are implemented as scripts which are
automatically invoked when the command you defined is used
in command-line mode. We will discuss user-defined commands
in more detail later on.
Compiling Scripts Compiling Scripts
Before executing a script file, PibTerm scans it and
converts it to an in-memory list of commands. This process
is called compiling the script. During the compilation compiling
process, you will be informed if any script command line is
syntactically bad. PibTerm stops scanning at the first line
in error. Any erroneous script statement prevents PibTerm
from executing the script.
Limitations on Script Size Limitations on Script Size
The size of a script is limited by the available memory to
hold the "compiled" script code. If there is not enough
memory for the script, it will not be executed. No
individual script can compile to more than 32767 bytes; this
should not pose any problems, since long scripts can be
broken up into a series of shorter scripts which can invoke
each other using the EXECUTE script command. EXECUTE
Script Library PIBTERM.SCL Script Library PIBTERM.SCL
The file PIBTERM.SCL provides a simple script library PIBTERM.SCL
facility. Versions of PibTerm prior to v4.0 required that
each script be stored in a separate file. This resulted in
considerable wasted disk space, since even a tiny script
PibTerm Script Language Reference Guide Page 3 PibTerm Script Language Reference Guide Page 3
took up a large block of disk space. The file PIBTERM.SCL
may contain many scripts; since it it is one large file,
disk space is more efficiently used.
PIBTERM.SCL is a straightforward ASCII text file. The
scripts contained in it follow one right after the other,
separated by a line beginning (in column one) with two equal
signs and the name of the script. For example, if we have
three scripts, named WINKEN, BLINKEN, and NOD, then
PIBTERM.SCL would look like this:
==WINKEN
-- text of winken.scr
==BLINKEN
-- text of blinken.scr
==NOD
-- text of nod.scr
^
|
column 1
Script entries will be searched for sequentially in this
file. Thus, you should place the most commonly used scripts
at the front of PIBTERM.SCL.
PIBTERM.SCL must reside in the main PibTerm directory
(pointed to by SET PIBTERM=).
You may place the primary script file to be executed in
PIBTERM.SCL instead of creating a separate PIBTERM.SCR file.
For this to work, the following conditions must hold:
1. No PIBTERM.SCR exists.
2. ==PIBTERM is the FIRST LINE (and therefore the
first script) in PIBTERM.SCL.
This execution order is taken regardless of any script order
configuration settings (see next section).
Search Order For Scripts Search Order For Scripts
The new parameter SF= provides the name of the directory
containing the (separate file) scripts to be executed. If
SF is the null string, then the current directory is used.
SF= can be set from the <ALT>P P)aths menu.
Scripts may executed from separate files or from the library
file PIBTERM.SCL. The new parameter SO= defines the order
in which a search for a script is performed:
PibTerm Script Language Reference Guide Page 4 PibTerm Script Language Reference Guide Page 4
SO=0: SF= directory, then PIBTERM.SCL (default)
SO=1: PIBTERM.SCL then SF=
SO=2: SF= only (ignore PIBTERM.SCL)
SO=3: PIBTERM.SCL only (ignore SF= and any scripts
contained there)
Terminating Execution Of A Script Terminating Execution Of A Script
To stop executing a script, use the <ALT>X command. If a
script is executing, you will be prompted as to whether or
not you want to stop executing the script. If you then want
to exit PibTerm, type <ALT>X again.
You can also use the EXIT and EXITALL script commands to EXIT EXITALL
terminate a script from within a script, or from command
line mode.
Automatic Script Generation -- The Learn Facility Automatic Script Generation -- The Learn Facility
If you hit Enter after striking <ALT>G, you are presented
with a list of scripts available for execution as well as
several other facilities. One of these is the "Learn a
script." This option opens a file to receive a specially
edited transcript of the communications session in which the
local and remote input and output are transformed into
script commands. This allows PibTerm to "learn" a sequence
of script commands which you can edit and use again later.
When you start a learn script sequence, you are prompted for
the maximum number of characters to be generated in any
WAITSTRING and also for the maximum number of lines (defined
by a string of characters ended with CR or LF) to be
generated in any WAITSTRING. Usually choosing the defaults
of 30 characters and 1 line produces good results.
You usually need to touch up the generated script manually.
See the "Guide to PibTerm" for more details on learning a
script.
Script File Commands Script File Commands
Script file commands consist of an initial command word
possibly followed by zero or more arguments. Blank lines or
lines beginning with an "*" may be used as comments. Many
of the commands perform similar functions to the regular
<Alt>letter keyboard entries described in the PibTerm Guide.
Here is a complete list of PibTerm script commands with a
brief description of the purpose of each. A detailed
description of each command will be given later.
PibTerm Script Language Reference Guide Page 5 PibTerm Script Language Reference Guide Page 5
AddCommand adds a user-defined command to PibTerm script AddCommand
language
AddLF adds line feeds to carriage returns. AddLF
Alarm issues five beeps Alarm
Break issues a break sequence (like <ALT>B). Break
Call calls internal script procedure Call
Capture toggles session capture to specified file Capture
(like <ALT>O).
Case selection block header for DOCASE statement Case
ChDir changes current directory ChDir
Clear clears the screen (like <ALT>C). Clear
Close closes specified file Close
ClrEol clears display from cursor to end of line on ClrEol
screen
ComDrain drains serial port output ring buffer ComDrain
ComFlush flushes ring buffers for serial port ComFlush
CopyFile copies one file to another CopyFile
Declare provides name, type, and initial value for Declare
script variable
Delay delays PibTerm execution for specified length Delay
of time.
DelLine deletes current line in screen display DelLine
Dial dial a number in the dialing directory (like Dial
<ALT>D).
DirFirst finds first file matching a wildcard DirFirst
specification
DirNext finds subsequent files matching a wildcard DirNext
specification
DoCase starts multiway selection statement DoCase
Dos executes a specified DOS command (somewhat Dos
like <ALT>J).
PibTerm Script Language Reference Guide Page 6 PibTerm Script Language Reference Guide Page 6
Echo toggles local echo (like <ALT>E). Echo
EditFile invokes the currently defined editor (usually EditFile
the built-in PibTerm editor)
Else FALSE branch of an IF statement. Else
EndCase ends a Case block EndCase
EndDoCase ends a DoCase statement EndDoCase
EndFor ends FOR loop EndFor
EndIf ends an IF statement. EndIf
EndProc ends an internal script procedure EndProc
EndWhile ends a WHILE statement. EndWhile
EraseFile erases (deletes) a file EraseFile
Execute executes another script Execute
Exit stop executing the script. Exit
ExitAll exits nested scripts ExitAll
For starts For loop For
FreeSpace finds free space on drive FreeSpace
GetDir gets current drive and directory GetDir
GetParam gets value of a PibTerm parameter GetParam
GetVar gets value of a PibTerm variable GetVar
GoToXY positions cursor at specified screen GoToXY
coordinates
HangUp hangs up the phone (like <ALT>H). HangUp
Host enters Host mode (like <ALT>W). Host
If test for several different types of If
conditions; Else is also available and Endif
terminates an IF block.
Import declares variable passed to nested script Import
invoked using Execute
InsLine inserts line at current cursor position on InsLine
screen
PibTerm Script Language Reference Guide Page 7 PibTerm Script Language Reference Guide Page 7
Input prompt for input from local user. Input
Key sets function keys from specified file (like Key
<ALT>K "Read definitions from a file").
KeyFlush flushes current keyboard buffer KeyFlush
KeySend sends specified function key's definition to KeySend
remote system.
Log toggles session logging on printer (like Log
<ALT>L).
Menu displays pop-up menu Menu
Message display message on PC's screen; message is Message
not sent to remote system.
Mute toggles mute mode (like <ALT>M). Mute
Open opens a file Open
Param sets program parameters Param
PrintFile starts printing of a file using built-in PrintFile
PibTerm spooling facility
Procedure defines start of internal script procedure Procedure
Read reads characters from a file Read
Readln reads a line from a file Readln
Receive receives a file from a remote system (like Receive
<ALT>R).
Redial redials the last phone number entered (like Redial
<ALT>Q).
Repeat begins block of statements to be repeatedly Repeat
executed until condition on matching UNTIL
statement is true.
Reset starts executing script from the beginning Reset
again.
Return returns from internal script procedure to Return
calling procedure
RInput prompt for input from remote system. RInput
Send sends a file to a remote system, like <ALT>S. Send
PibTerm Script Language Reference Guide Page 8 PibTerm Script Language Reference Guide Page 8
Set sets value of a script variable Set
SetParam sets value of a PibTerm parameter SetParam
SetVar sets value of a script variable SetVar
SText send text to remote system, and interpret SText
embedded characters like function key
characters.
Suspend suspends script execution for specified Suspend
length of time (PibTerm continues executing).
Text send text to remote system without Text
interpretation.
Translate reads in a translation table (like <ALT>T). Translate
Until terminates REPEAT block and provides Until
termination condition.
ViewFile invokes currently defined file viewer ViewFile
(usually built-in PibTerm file viewer)
Wait stops PibTerm execution until a specified Wait
time (in HH:MM:SS form) is reached, at which
time execution proceeds.
WaitCount waits for specified number of characters to WaitCount
appear from remote system
WaitList waits for any one of a list of strings to WaitList
appear from remote system
WaitQuiet waits for serial port input to quiesce WaitQuiet
WaitString waits for a given string to appear from the WaitString
remote system (only done once).
WaitTime sets wait time for other wait commands WaitTime
When waits for a given string to appear from the When
remote system, and then sends a specified
response string (done as often as required
string appears).
WhenDrop specifies action to take when carrier drops WhenDrop
WhereXY returns current cursor position on screen WhereXY
While begins block of statements to be repeatedly While
executed as long as specified condition is
true. A While block is terminated by an
EndWhile statement.
PibTerm Script Language Reference Guide Page 9 PibTerm Script Language Reference Guide Page 9
Write writes characters to a file Write
Writeln writes a line to a file Writeln
WriteLog writes text to log/capture files WriteLog
General Syntax of Script Commands General Syntax of Script Commands
Here are some general comments about script command syntax:
1. Command names may be entered in any case; "CLEAR" =
"Clear" = "ClEaR".
2. Each command must fit on a single input line. There is
no provision for multi-line commands.
3. When quoted strings are called for, either single or
double quotes may be used. To insert a quote into a
string in which that same quote is being used as the
string delimiter, write two adjacent quotes. For
example, the string
Here's a string
can be written as:
'Here''s a string'.
4. Quoted strings cannot span a line. Unclosed quotes
cause an error.
Script Variable Names Script Variable Names
The PibTerm script language includes variables as well as
commands. Script variable names may be up to ten characters
long, and may contain letters and digits. Case is ignored.
The first character must be a letter.
Examples:
Abc
c34
ABC (same as Abc)
thelongone
PibTerm Script Language Reference Guide Page 10 PibTerm Script Language Reference Guide Page 10
Declaring variables Declaring variables
You may declare script variables using the Declare script Declare
command. ALL script variables MUST appear in a Declare
command. Each Declare defines only one variable.
The syntax of a Declare statement is:
DECLARE name type S3
where name is the variable name, type is the variable type, name type
and S3 is the initial value of the variable. S3 may be
either a string variable or a string constant.
Note that neither the name nor the type is enclosed in
quotes.
Case is not important in variable names.
The following types are available:
INTEGER An integer value from -2147483648 to 2147483647 INTEGER
(beginning with PibTerm v4.1 -- in PibTerm v4.0,
values were limited to the range -32768 to 32767).
STRING A variable length string of maximum size 255 STRING
characters.
Examples:
DECLARE Abc String 'ABC'
-- a string of maximum length 255 with initial
value ABC
DECLARE c Integer
-- 'c' is an integer with initial value 0
When no initial value is provided a string variable is
assigned the null string as a value when it is declared. A
numeric variables is set to zero if no initial value if
provided.
ABC, Abc, AbC, etc. are all the same variable name. Case
doesn't matter in variable names.
Saving variable values after script ends Saving variable values after script ends
Variables disappear when the last script in a stack of
nested scripts is finished executing. If you want to carry
over the variable values from one script execution to
another, you can use the text file facilities to store
PibTerm Script Language Reference Guide Page 11 PibTerm Script Language Reference Guide Page 11
information on MS DOS files between script invocations.
Alternatively, you can store variable values in (unused)
function keys (see the KeyDef script command and the KeyDef
KeyString function in the Set script command). KeyString Set
Each script gets it own set of variables. It is possible
for one script to invoke another, and for those two scripts
to share variables. This is done using the Import facility
described later.
Detailed Description of Script Commands Detailed Description of Script Commands
The following sections detail each script command. The
examples for some commands use other commands which will not
be described until later. You may need to make two passes
through these descriptions in order to fully understand the
examples.
In what follows, any variable name beginning with a 'S'
indicates a string variable or constant, and any variable
starting with 'I' indicates an integer variable or constant.
(Note: It is assumed that variables have been properly
declared using the DECLARE statement.)
AddCommand -- Add User-Defined Command AddCommand -- Add User-Defined Command
PibTerm allows you to define up to one hundred new commands.
This is primarily useful when PibTerm is being used in
command key mode.
The script command AddCommand adds a new command. It has AddCommand
the syntax:
AddCommand Sname Script
Sname is the name of the command to be added, which may be Sname
up eight characters long.
Script is the name of the script to be invoked when the Script
command is encountered either in a script or (more likely)
when entered in command key mode.
Both Sname and Script may be either string variables or Sname Script
string constants.
The best way to set up a list of commands to be added is to
place all the AddCommand definitions in the default
PIBTERM.SCR which will be automatically executed at startup
time.
If you write a command with the same name as an existing
PibTerm script command, then your version will override the will override
PibTerm Script Language Reference Guide Page 12 PibTerm Script Language Reference Guide Page 12
built-in command. You may still want access to the built-in
command -- for example, if you're writing a spiffy front-end
for a built-in command. To request the original command
name, precede it by a '$'. '$'.
For example, suppose you write a new RECEIVE command, but RECEIVE
you still want access to the original RECEIVE. Then you can RECEIVE
write $RECEIVE where you want the reference to be to the $RECEIVE
original built-in RECEIVE command. RECEIVE
To illustrate how to add a command, suppose that you want to
define an EMULATE command for PibTerm. Also suppose that the
script containing the code to perform the EMULATE command is
in the script file EMULATE.SCR. Then you could write: EMULATE.SCR
AddCommand 'Emulate' 'Emulate.scr'
Now if you enter a command like:
Emulate VT100
then control is passed to 'Emulate.scr' to process that
input line. When the script gains control, all of the text
following the command name 'Emulate' itself is stored as a
parameter line. The contents of that parameter line can be
accessed using the ParamLine command, or pieces may be
broken out using the ParamCount and ParamStr string
functions. ParamCount and ParamStr operate like the
standard Turbo Pascal functions of the same name, except
that they operate on the command line text, not the PibTerm
parameter text: ParamCount counts the number of (blank-
delimited) command line entries, and ParamStr(i) returns the
ith command-line entry.
To make this clearer, here is the text for a sample
EMULATE.SCR script:
*******************************************************************
* *
* Emulate.scr --- Command processor to set terminal emulation. *
* Use ADDCOMMAND 'Emulate' 'Emulate.scr' to *
* activate this function. *
* *
* Use: *
* *
* Emulate terminalname *
* *
* terminalname -- name of terminal (e.g., VT100) to *
* emulate. *
* *
*******************************************************************
*
Declare TermName String
*
PibTerm Script Language Reference Guide Page 13 PibTerm Script Language Reference Guide Page 13
* Pick up terminal name from command line text.
*
IF ( ParamCount > 0 ) THEN
Set TermName = UpperCase( ParamStr( 1 ) )
ELSE
Set TermName = ' '
ENDIF
*
* Set terminal type depending upon name.
*
DOCASE TermName OF
CASE 'DUMB'
Message "Dumb terminal chosen."
SetParam 'te' '0'
ENDCASE
CASE 'VT52'
Message "VT52 terminal chosen."
SetParam 'te' '1'
ENDCASE
CASE 'ANSI'
Message "ANSI/BBS terminal chosen."
SetParam 'te' '2'
ENDCASE
CASE 'VT100'
Message "VT100 terminal chosen."
SetParam 'te' '3'
ENDCASE
CASE 'GOSSIP'
Message "Gossip mode chosen."
SetParam 'te' '4'
ENDCASE
CASE 'TEK4010'
Message "Tek 4010 terminal chosen."
SetParam 'te' '6'
ENDCASE
CASE 'ADM3A'
Message "ADM3a terminal chosen."
SetParam 'te' '7'
ENDCASE
CASE 'ADM5'
Message "ADM5 terminal chosen."
SetParam 'te' '8'
ENDCASE
CASE 'TV925'
Message "Televideo 925 terminal chosen."
SetParam 'te' '10'
ENDCASE
CASE ELSE
Message "Bogus terminal choice!"
ENDCASE
ENDDOCASE
PibTerm Script Language Reference Guide Page 14 PibTerm Script Language Reference Guide Page 14
AddLF -- Add Line Feeds AddLF -- Add Line Feeds
AddLF toggles the addition of a line feed to each carriage AddLF
return received from the remote system. This is useful when
accessing remote systems that expect a carriage return to
also act as a line feed. Not many system do that anymore.
However, occasionally a system accessed using FTP over
ArpaNet doesn't send the <CR><LF> sequence, just <CR>, so
AddLF is a handy way to rectify that problem.
Alarm -- Issues Five Beeps Alarm -- Issues Five Beeps
Alarm issues five beeps as long as mute mode is turned off. Alarm
Break -- Send Break Break -- Send Break
Break issues a break signal over the communications port. Break
This is exactly the same as hitting the <ALT>B. The length
of the break signal is controlled by the BL= parameter.
Call -- Call Internal Script Procedure Call -- Call Internal Script Procedure
Call invokes an internal script procedure. See the Call
Procedure command below for more details. Procedure
Capture -- Capture Session To Disk Capture -- Capture Session To Disk
Capture toggles session capture to a specified file. The Capture
syntax of the capture command is:
Capture Sname Scaptype
Sname is the name of the file to capture to. Sname
Scaptype indicates the type of capture to be performed. Scaptype
"E" specifies an edited capture and "U" specifies an
unedited capture. An edited capture displays the lines as
they appear on the screen. An unedited capture writes
characters as they arrive from the remote system.
For example, to initiate edited session capture to file
"GETIT.DAT", use the script command:
Capture "GETIT.DAT" "E"
If the script variable 'Sname' contains "GETIT.DAT", you
could also write:
Capture Sname "E"
PibTerm Script Language Reference Guide Page 15 PibTerm Script Language Reference Guide Page 15
To turn off capture later in the same script, just enter
Capture with no argument:
Capture
Be careful -- if you enter Capture with no arguments, and
you have not previously requested session capturing, then
PibTerm will issue a prompt for the capture file name, if
PibTerm is running in attended mode. The intent here is to
provide flexibility when running a script in attended mode;
but if you're not careful, you may find an unattended script
gets hung up waiting for the capture file name entry. In
unattended mode, the spurious Capture is ignored.
Case -- Case Selector For DoCase Case -- Case Selector For DoCase
Case marks the start of a Case/EndCase block in a DoCase Case
statement. See the DoCase statement definition for further DoCase
details.
ChDir -- Change Current Directory or Drive ChDir -- Change Current Directory or Drive
ChDir changes the current logged directory and/or drive. ChDir
The syntax is:
CHDIR Sdir
Sdir is either a string variable or constant containing the Sdir
name of the new directory, drive, or both in standard MS DOS
directory format.
Examples:
ChDir 'c:\modem'
Set mydir = 'b:\bogus'
ChDir mydir
ChDir 'b:'
Set mydrive = 'b:'
ChDir mydrive
Clear -- Clear Screen Clear -- Clear Screen
Clear clears the screen (except for the status line). This Clear
is just like the <ALT>C keyboard command.
PibTerm Script Language Reference Guide Page 16 PibTerm Script Language Reference Guide Page 16
Close -- Close File Close -- Close File
Close closes a file opened using the script command Open Close Open
(see below). The syntax is:
CLOSE Ifile
IFile is the index of the file to be closed. IFile
*
Declare MyFile Integer
*
Close 1
Set Myfile = 3
Close Myfile
ClrEol -- Clear Display To End Of Line ClrEol -- Clear Display To End Of Line
ClrEol clears the display beginning with the current cursor ClrEol
position and continuing to the end of the line on the
screen.
ComDrain -- Drain Serial Port Output Buffer ComDrain -- Drain Serial Port Output Buffer
ComDrain waits a specified number of seconds for the serial ComDrain
port output buffer to empty. The syntax is:
ComDrain IWaitSecs
where "IWaitSecs" is the number of seconds to wait for the IWaitSecs
buffer to become empty. Execution of the script continues
with the next statement when either the buffer is drained or
the number of seconds to wait is exceeded.
ComFlush -- Flush Serial Port Buffers ComFlush -- Flush Serial Port Buffers
ComFlush flushes or drains the serial port buffers. The
syntax is:
ComFlush Sflushtyp
where "Sflushtyp" is a string constant or variable which Sflushtyp
indicates which serial port buffers are to be flushed:
'I' Flush input buffer only
'O' Flush output buffer only
'B' Flush both buffers
If no Sflushtyp appears, both the input and output buffers Sflushtyp
are flushed.
PibTerm Script Language Reference Guide Page 17 PibTerm Script Language Reference Guide Page 17
The input buffer is flushed by throwing away the current
contents of the buffer -- i.e., any character received from
the remote system but not yet processed by PibTerm -- and
then waiting for the port to become briefly inactive.
The output buffer is flushed by throwing away the contents
of the buffer, i.e., any characters waiting to be sent to
the remote system.
CopyFile --- Copy File CopyFile --- Copy File
CopyFile copies one file (of any type) to another. The copy CopyFile
proceeds byte-by-byte and is not limited to text files. The
syntax is:
COPYFILE Sorig Scopy
Sorig is the original file to be copied. Sorig
Scopy is the resultant copy. Scopy
Delay -- Delay Execute for Specified Interval Delay -- Delay Execute for Specified Interval
Delay delays PibTerm execution for the number of tenths of a Delay
second specified by the argument. The syntax is:
Delay Idelay
For example,
Delay 10
delays PibTerm execution for one second (ten tenths = one).
To delay execution for half a second, enter:
Delay 5
If the script variable Delaytime contains a 5, then you
could write:
Declare DelayTime Integer
Set DelayTime = 5
Delay Delaytime
to delay execution for half a second.
Delay differs from the Suspend command described below. The Delay Suspend
Suspend command only halts SCRIPT processing for the
specified length of time. Delay halts ALL PibTerm
processing (except the asynchronous reception of incoming
characters).
PibTerm Script Language Reference Guide Page 18 PibTerm Script Language Reference Guide Page 18
DelLine -- Delete Current Line On Screen DelLine -- Delete Current Line On Screen
DelLine deletes the display line on which the cursor rests. DelLine
All lines below the deleted line (except the status line)
are scrolled up.
Dial -- Dial A Number Dial -- Dial A Number
Dial dials a number in the PibTerm dialing directory, just Dial
like <ALT>D. The number to be dialed can be specified as a
string variable or string constant. The syntax for Dial is:
DIAL Sdial NOSCRIPT
SDial specifies the entry to be dialed. SDial
NOSCRIPT (written without quote marks) indicates that the NOSCRIPT
automatic invocation of the associated dialing script, if
any, is to be suppressed.
For example, to dial directory entry 3, use the command:
Dial "3"
You can add the dialing prefix characters if you wish:
Dial "-3"
You can also request a manual dial by prefixing the entire
number with an M:
Dial "M1234567"
If the string variable EntryNum contains "-3" then you can
write:
Dial EntryNum
If you don't want the associated script for entry 3 to be
invoked, then write:
Dial EntryNum NOSCRIPT
DirFirst -- Find First Matching File DirFirst -- Find First Matching File
DirFirst, combined with DirNext (described below), allows DirFirst DirNext
you to search DOS directories for file names matching a
wildcard specification. The syntax of DirFirst is:
DirFirst Spec Srchattr Sname Sattr Sdate Stime Size
PibTerm Script Language Reference Guide Page 19 PibTerm Script Language Reference Guide Page 19
Spec is a string containing the wildcard specification for Spec
the search. Only files matching this specification will be
selected. Here are some examples of legal wildcards:
*.* All files.
c:\bogus\*.pas All files in subdirectory *.pas
with the extension '.pas'.
myfile.dat Only the file 'myfile.dat'.
Srchattr is a string which specifies which file attributes Srchattr
should be searched for. Only files matching the specified
attributes will be selected. Here are the various attribute
letters and meanings:
A Archive bit set
D Directory
H Hidden
N Normal file
R Read-only
S System
V Volume label
You may combine attributes. Specifying a null string for
SrchAttr means the same thing as combining ALL of the SrchAttr
attributes. Here are some examples:
"N" Select normal files only
"HS" Select hidden system files only
"V" Select volume label only
"" Select ALL files
Refer to your DOS manual for details about these file
attributes.
Sname gets the name of the first file (if any) matching the Sname
given specification and attributes. If no files match, then
Sname will be an empty string. Sname
Sattr gets the attributes associated with the file as a Sattr
string. The attribute string is composed of the same
letters described above for the Srchattr parameter. Note Srchattr
that there may be MORE attributes for a particular file in
Sattr than in Srchattr. Sattr Srchattr
Sdate gets the creation date of the file as a string. The Sdate
date format is controlled by the setting of the DF=
parameter (see the PibTerm Parameter Reference Manual).
Stime gets the creation time of the file as a string. The Stime
time format is controlled by the TF= parameter.
Size gets the size of the file in bytes as a string. Size
PibTerm Script Language Reference Guide Page 20 PibTerm Script Language Reference Guide Page 20
Here is an example in which DirFirst is used to retrieve and
display the volume label of the current logged drive (DOS
3.0 and above only):
Declare VolID String
Declare Drive String
Declare Dir String
Declare Attr String
Declare Date String
Declare Time String
Declare Size String
*
* Get current drive/dir
*
GetDir Drive Dir
*
* Append colon to drive
*
Set Drive = CONCAT( Drive , ':' )
*
* Look for volume label
*
DirFirst Drive "V" VolID Attr Date Time Size
*
* Display if found
*
IF ( VolID <> '' ) THEN
Set VolID = CONCAT( 'Volume: ', VolID )
Set VolID = CONCAT( CONCAT( VolID , ' Created: ' ), Date )
Set VolID = CONCAT( CONCAT( VolID , ' ' ), Time )
Writeln
Writeln VolID
ELSE
Writeln
Writeln "Volume label not found."
ENDIF
DirNext -- Find Next Matching File DirNext -- Find Next Matching File
DirNext returns further files matching a wildcard DirNext
specification provided by a previously executed DirFirst.
The syntax of DirNext is:
DirNext Sname Sattr Sdate Stime Size
where Sname through Size have the same meanings as for Sname Size
DirFirst above.
Here is a script which prompts for a file specification to
be searched for, and then lists the matching files and sizes
on the display:
PibTerm Script Language Reference Guide Page 21 PibTerm Script Language Reference Guide Page 21
* Wildcard for files
Declare FSpec String
* Attributes for search
Declare FAttr String
* File name
Declare FileName String
* File attributes
Declare FileAttr String
* File creation date
Declare FileDate String
* File creation time
Declare FileTime String
* File size in bytes
Declare FileSize String
* Report line
Declare ReportLine String
* Counts files found
Declare TotalFiles Integer
*
* Get file spec to search for
*
Writeln
Input "Enter file spec to search for: " FSpec
Writeln
*
* If file spec null, quit.
*
IF ( FSpec = '' ) THEN
Exit
ENDIF
*
* Search for first file.
*
DirFirst FSpec "" FileName FileAttr FileDate FileTime FileSize
*
* No first file -- report that
* and quit.
*
IF ( ( FileName = '' ) OR ( IOResult <> 0 ) ) THEN
Writeln
Writeln "No files found."
Writeln
Exit
ENDIF
* Set files found to 0.
Set TotalFiles = 0
*
* Begin loop over rest of files.
*
WHILE ( LENGTH( FileName ) <> 0 ) DO
*
* Increment file count
*
PibTerm Script Language Reference Guide Page 22 PibTerm Script Language Reference Guide Page 22
Set TotalFiles = TotalFiles + 1
*
* Display file stuff
*
Set FileName = CONCAT( FileName , DUPL( ' ' , 14 - LENGTH( FileName ) ) )
Set FileSize = CONCAT( DUPL( ' ' , 12 - LENGTH( FileSize ) ) , FileSize )
Set FileSize = CONCAT( FileSize , ' ' )
Set FileDate = CONCAT( FileDate , ' ' )
Set FileTime = CONCAT( FileTime , ' ' )
*
Set ReportLine = CONCAT( CONCAT( FileName , FileSize ), FileDate )
Set ReportLine = CONCAT( CONCAT( ReportLine , FileTime ), FileAttr )
*
Writeln ReportLine
* Get next file
*
DirNext FileName FileAttr FileDate FileTime FileSize
*
ENDWHILE
* Display final count of files
*
Set ReportLine = CONCAT( 'Total files found: ', STRING( TotalFiles ) )
*
Writeln
Writeln ReportLine
DoCase -- Do Case Statement DoCase -- Do Case Statement
The DoCase statement starts a multiway selection block. DoCase
The syntax of DoCase is as follows:
DOCASE var
CASE value1
...
ENDCASE
CASE value2
...
ENDCASE
...
CASE ELSE
...
ENDCASE
ENDDOCASE
'var' can be either an integer or a string variable.
'value1', 'value2', etc. are the case-selection values. If
the value of 'var' matches one of the 'value(n)' values,
then the statements following that CASE value(n) are
executed. CASE ELSE provides a means for executing
statements if the value of 'var' matched none of the
'value(n)' values.
PibTerm Script Language Reference Guide Page 23 PibTerm Script Language Reference Guide Page 23
DoCase provides a convenient alternative to a long series of
nested IF statements.
Examples:
DECLARE I Integer
DECLARE S String
...
DOCASE I
CASE 1
...
ENDCASE
CASE 2
...
ENDCASE
CASE 3
...
ENDCASE
CASE ELSE
...
ENDCASE
ENDDOCASE
DOCASE S
CASE 'VT100'
...
ENDCASE
CASE 'VT52'
...
ENDCASE
CASE 'ANSI'
...
ENDCASE
CASE ELSE
...
ENDCASE
ENDDOCASE
For another example, see the definition of the EMULATE.SCR
script in the description of the AddCommand command above.
Dos -- Execute DOS Command Dos -- Execute DOS Command
Dos executes a specified DOS command -- somewhat like Dos
<ALT>J, but only for a single command. The syntax is:
Dos Sdos
Sdos specifies the DOS command to be executed. Sdos
For example, to execute a DIR command, enter:
Dos "DIR"
PibTerm Script Language Reference Guide Page 24 PibTerm Script Language Reference Guide Page 24
If the script variable 'Doscom' contains 'DIR' you could
write:
Dos Doscom
To jump to a new copy of DOS, write:
Dos ""
Dos automatically returns to PibTerm after executing the Dos
single specified MS DOS command, unless the specified
command is null. In that case, Dos invokes a new level of Dos
the MS DOS command processor, and you will have to enter
EXIT to return to PibTerm. This is the same behavior as for
the <ALT>J command.
Echo -- Toggle Local Echo Echo -- Toggle Local Echo
Echo toggles local echo mode, just like the keyboard entry Echo
<ALT>E. In local echo mode, PibTerm displays characters as
you type them, and doesn't wait for the remote system to
echo them back.
EditFile -- Invoke File Editor EditFile -- Invoke File Editor
EditFile invokes the currently defined editor specified by
the EN= parameter. If the value of EN= is null, then the
built-in PibTerm editor is invoked. Otherwise, the string
specified as the value of EN= is executed as a DOS command,
after making any required file name substitution (see the
description of the EN= parameter in the "PibTerm Parameter
Reference Manual" for details).
The syntax of EditFile is:
EditFile Sname
Sname specifies the name of the file to be edited. Sname
For example, to invoke the editor for file "BOGUSCO.DAT",
you could write:
EditFile "Bogusco.dat"
Else -- Part Of IF Statement Else -- Part Of IF Statement
Else is described as part of the If command below. Else
PibTerm Script Language Reference Guide Page 25 PibTerm Script Language Reference Guide Page 25
EndCase -- Ends Case Block EndCase -- Ends Case Block
EndCase is described as part of the DoCase command above. EndCase
EndDoCase -- Ends DoCase Statement EndDoCase -- Ends DoCase Statement
EndDoCase is described as part of the DoCase command above. EndDoCase
EndIf -- Ends an IF Statement EndIf -- Ends an IF Statement
EndIf is described as part of the 'If' command below. EndIf
EndProc -- Ends a Script Procedure EndProc -- Ends a Script Procedure
EndProc is described as part of the Procedure command below. EndProc
EndWhile -- Ends a WHILE Block EndWhile -- Ends a WHILE Block
EndWhile is described as part of the 'While' statement EndWhile
below.
EraseFile -- Erase (Delete) A File EraseFile -- Erase (Delete) A File
EraseFile erases (deletes) a file. The syntax is: EraseFile
EraseFile Sname
Sname specifies the name of the file to be erased. Sname
For example, to erase the file "BOGUSCO.DAT", you could
write the following script command:
EraseFile "Bogusco.dat"
This is equivalent to issuing the DOS command:
ERASE BOGUSCO.DAT
Execute -- Execute One Script From Another Execute -- Execute One Script From Another
Scripts may invoke other scripts. The Execute script Execute
command provides the necessary mechanism. The syntax of the
Execute command is:
Execute Sname <Arguments>
Sname is the name of the script to be invoked. Sname
PibTerm Script Language Reference Guide Page 26 PibTerm Script Language Reference Guide Page 26
<Arguments> is a list of variables or constants (but NOT <Arguments
expressions) to be passed as arguments to the executed
script. This is essentially the same format as for calling
an internal script procedure (see Call), except that Sname Call Sname
here refers to an external script.
Here is a script which invokes three other scripts:
DECLARE I Integer
DECLARE S String
DECLARE name String 'Other2'
...
Message " "
Message "We will now invoke three scripts."
Message " "
Execute 'OTHER1' 23 'VT100' S
Execute name I
Execute 'OTHER3'
The three scripts OTHER1, OTHER2, and OTHER3 will be invoked
and executed.
The TYPE of the arguments passed is NOT CHECKED by PibTerm.
If you make a mistake, you may get bizarre results. The
NUMBER of arguments IS checked, and the invoked script will
NOT be executed if the wrong number of arguments is
provided.
Arguments are passed to a nested script using the Import Import
script statement. See the definition of Import for details.
The <ALT>X command exits one level of script nesting at a
time. You may need to repeat it several times to get out of
all the scripts. The script command Exitall will also take Exitall
you out of all scripts, regardless of nesting depth.
Here is an extended example of an executed script. Suppose
we want to construct a script to prompt a remote caller and
handle sending of files. The script will take two
arguments, the file name of the file(s) to be send, and the
transfer protocol. If either or both aren't specified, then
the executed script will prompt for them. We'll call this
script SENDIT:
IMPORT Filename String
IMPORT Protocol String
*
DECLARE Temp String
*
* Check if file name provided. Prompt if missing.
*
WHILE( LENGTH(FileName) = 0 ) DO
RInput "Enter name of file to transfer: " Filename
ENDWHILE
PibTerm Script Language Reference Guide Page 27 PibTerm Script Language Reference Guide Page 27
*
* Check if file exists. If not, quit.
*
IF ( NOT FILEEXISTS( Filename ) ) THEN
SET Temp = CONCAT( CONCAT( "The file ", Filename ), " does not exist.|")
SText Temp
Quit
ENDIF
*
* Check if protocol provided. Prompt if missing.
*
WHILE( LENGTH( Protocol ) = 0 ) DO
RInput "Enter protocol to use: " Protocol
ENDIF
*
* Check if protocol is legitimate; send file if so.
*
IF POS( Protocol , 'X,XC,Y,YB,TE' ) > 0 THEN
Send Filename Protocol
ELSE
SText "Invalid protocol name.|"
ENDIF
We could invoke this script as:
SENDIT '' ''
This would prompt the remote caller for the file name and
transfer type.
Exit -- Terminate Script Execution Exit -- Terminate Script Execution
Exit terminates execution of the script. PibTerm Exit
automatically inserts an Exit at the end of a script, so you Exit
need not provide it there. Exit is most useful when you
want to stop script execution somewhere in the middle of a
script.
Exit only stops the current script. If you are in a nested
script, control is returned to the invoking script. To exit
all scripts, use the ExitAll command instead.
Note that terminating a script does NOT terminate processing
of any defined 'When' string. See the section on the 'When'
script command below for further details.
ExitAll -- Exit Nested Scripts ExitAll -- Exit Nested Scripts
ExitAll stops executing the current script, regardless of ExitAll
the nesting depth. All higher-level scripts are also
stopped.
PibTerm Script Language Reference Guide Page 28 PibTerm Script Language Reference Guide Page 28
For -- Start FOR Loop For -- Start FOR Loop
A For loop has the form: For
FOR index = start-expression TO end-expression DO
...
other statements
...
ENDFOR
-or-
FOR index = start-expression DOWNTO end-expression DO
...
other statements
...
ENDFOR
'index' is an integer variable name; 'start-expression'
gives the initial loop value; 'end-expression' gives the
final loop value. 'TO' specifies an ascending loop; 'DOWNTO'
specifies a descending loop. The increment is always 1.
Examples:
DECLARE I Integer
...
FOR I = 1 TO 10 DO
...
ENDFOR
FOR I = 10 DOWNTO 1 DO
...
ENDFOR
FOR I := ( J * 10 - I ) TO ( K - 32 ) DO
...
ENDFOR
FreeSpace -- Find Free Space On Drive FreeSpace -- Find Free Space On Drive
FreeSpace finds the number of bytes of space which are still FreeSpace
unused on a drive. The syntax is:
FreeSpace Sdrive Sfree
Sdrive specifies the drive for which the free space is Sdrive
desired.
Sfree gets the free space as a string. Sfree
PibTerm Script Language Reference Guide Page 29 PibTerm Script Language Reference Guide Page 29
For example, to find the number of free bytes on drive C:
write:
Declare Size String
FreeSpace "C:" Size
Writeln Size
GetDir -- Get Current Directory And Drive GetDir -- Get Current Directory And Drive
GetDir retrieves the currently logged drive and MS DOS GetDir
subdirectory. The syntax is:
GETDIR Sdrive Sdir
Sdrive is a string variable which receives the current drive Sdrive
letter (without a trailing colon).
Sdir is a string variable which receives the current Sdir
subdirectory, without initial or trailing slashes.
Example:
Suppose that the current path is "c:\bogus". After
executing the following script statements:
Declare drive string
Declare drive dir
GetDir drive dir
The resulting values are:
drive contains C drive
dir contains BOGUS dir
GetParam -- Get Value of PibTerm Parameter GetParam -- Get Value of PibTerm Parameter
GetParam retrieves the current value of a PibTerm parameter GetParam
variable. The syntax is:
GetParam Spname Svalue
Spname is the two-character name of the parameter to be Spname
retrieved. Spname can be either a string variable or
constant.
Svalue is the current value of that parameter. Svalue must Svalue
be a string variable.
See the "PibTerm Parameters Reference Guide" for a complete
list of the parameter names and types.
PibTerm Script Language Reference Guide Page 30 PibTerm Script Language Reference Guide Page 30
Parameters whose values are integers are converted to string
form for storage in Svalue. Parameters whose values are Svalue
boolean are converted to "1" for a true value and "0" for a
false value.
Requesting a non-existent parameter name results in Svalue Svalue
being set to an empty string.
To avoid excessive code overlay swaps, try to keep a series
of GetParam statements together in your script.
Example:
Suppose that the current baud rate is 2400; that PibTerm is
NOT set for hard-wired access; and that the modem
initialization string is "ATZ". Then after executing the
following script statements:
*
Declare ModemInit String
Declare BaudRate String
Declare HardWired String
Declare PName String
*
* Get modem initialization string (string)
*
GetParam 'mi' ModemInit
*
* Get baud rate (integer variable)
*
Set PName = 'ba'
GetParam PName BaudRate
*
* Get hardwired status
*
GetParam 'hw' HardWired
the resulting values are (all strings):
ModemInit ATZ
BaudRate 2400
HardWired 0
GetVar -- Get Value of Script Variable GetVar -- Get Value of Script Variable
GetVar retrieves the current value of a script variable by GetVar
name. The syntax is:
GetVar Sname Stype Svalue
Sname is the name of the variable whose value is wanted. Sname
PibTerm Script Language Reference Guide Page 31 PibTerm Script Language Reference Guide Page 31
Stype returns the type ("INTEGER", "STRING") of the Stype
variable.
Svalue returns the current value of the variable, converted Svalue
to a string value if necessary. The most current instance of
the variable name is returned. That means in a nested
script or script procedure, the value from the most recent
definition of the variable is used.
If the given variable name doesn't exist, the type is
returned as "UNDEFINED" and the value is returned as an
empty string.
GetVar is useful when you don't know the name of the
variable for which you want a value until the script is
being executed. If you do know the name of the variable,
you should use the Set command instead, which is more Set
efficient.
As an example, suppose that the variable VARA is a string VARA
variable with the current value "bogus value". Then after
executing the following script statements:
Declare vtype string
Declare vval string
Declare vname string
...
GetVar 'VARA' vtype vval
SET vname = 'VARA'
GetVar vname vtype vval
the resulting values are:
vname VARA
vtype STRING
vval bogus value
GoToXY -- Move To Specified Screen Position GoToXY -- Move To Specified Screen Position
GoToXY positions the cursor to a specified row and column on GoToXY
the screen. The syntax is:
GoToXY IX IY
IX is the new column position, and IY is the new row IX IY
position.
Examples:
*
* Move to column 1, row 12
*
PibTerm Script Language Reference Guide Page 32 PibTerm Script Language Reference Guide Page 32
GoToXY 1 12
*
* Move to column 2, row 23
*
Set I1 = 2
Set I2 = 23
GoToXY I1 I2
Hangup -- Hang Up The Phone Hangup -- Hang Up The Phone
Hangup hangs up the phone, just like the keyboard entry Hangup
<ALT>H.
Host -- Enter Host Mode Host -- Enter Host Mode
Host causes PibTerm to enter Host mode, just like the Host
keyboard command <ALT>W. In this mode PibTerm acts like a
mini-BBS (bulletin board system). Remote callers can dial
your system and transfers files and leave messages. See the
section on PibTerm host mode in the "PibTerm User's Guide"
for more details.
If -- Conditionally Execute Statements If -- Conditionally Execute Statements
If allows testing of several different types of conditions If
and conditionally executing a block of statements. The
general form of the 'If' statement in PibTerm is:
IF ( condition ) THEN
< script statements executed if condition is TRUE >
ELSE
< script statements executed of condition is FALSE >
ENDIF
The Else part is optional and need not be specified. You Else
MUST specify the Endif. IF statements can be nested up to Endif
64 levels deep.
The "( condition )" must be an expression which evaluates to
either zero (false) or non-zero (true). Basically, the
"condition" is of the form "v1 OP v2" where v1 and v2 are v1 v2
script variables or functions, and OP is a relational OP
operator. The available functions are described under the
Set command below. The available relational operators are: Set
=, <, >, <>, <=, >=, NOT, AND, OR, XOR
Examples:
IF ( a = b ) THEN
PibTerm Script Language Reference Guide Page 33 PibTerm Script Language Reference Guide Page 33
...
ENDIF
IF ( a <> 'Where''s the beef?' ) THEN
...
ENDIF
IF ( c <= 25 ) THEN
...
ENDIF
IF ( NOT ( a = b ) ) THEN
...
ENDIF
Compound conditions are allowed, for example:
IF ( ( a = b ) AND ( NOT CONNECTED ) ) THEN
...
ENDIF
String comparisons use the ASCII character set as a
collating sequence.
These same conditional expressions can be used in all of the
other conditional commands like WHILE, UNTIL, and so on.
Import -- Import Variable To Executed Script Import -- Import Variable To Executed Script
A script invoked using the Execute script statement needs to Execute
indicate which variables are being passed to it. This is
done using the IMPORT command, which has the syntax:
Import varname type
Imported variables may be used just like Declared variables.
You can also Declare variables which will be local to the
Executed script. Execute
Here is the same main script as given in the Execute command
description:
DECLARE I Integer
DECLARE S String
DECLARE name String 'Other2'
...
Message " "
Message "We will now invoke three scripts."
Message " "
Execute 'OTHER1' 23 'VT100' S
Execute name I
Execute 'OTHER3'
PibTerm Script Language Reference Guide Page 34 PibTerm Script Language Reference Guide Page 34
The first three statements of script OTHER1 above might look
like this:
IMPORT N Integer
IMPORT TermType String
IMPORT Message String
...
The Import statements connect the variables N, TermType, and
Message in the script OTHER1 with the variables passed from
the main script, which may have quite different names. For
example:
Execute 'other1' 23 'vt100' S
results in the following matchups:
N <-- 23
TermType <-- 'VT100'
Message <-- S
As with internal script procedures, you may alter the values
of IMPORTed variables and the new values ARE passed back to
the invoking script IF the corresponding argument is a
variable. Changes in constants are NOT passed back to the
invoking script.
Input -- Get Input From Keyboard Input -- Get Input From Keyboard
Input prompts for and reads characters from the keyboard. Input
The syntax is:
Input Sprompt Sinput
Sprompt contains the prompt string, which may be the null Sprompt
string, in which case no prompt is issued.
Sinput receives the characters typed up to (but not Sinput
including) the terminating carriage return.
PibTerm Script Language Reference Guide Page 35 PibTerm Script Language Reference Guide Page 35
Example:
*
* Read letter into variable answer
*
Declare answer string
Declare prompt string
*
Input 'Enter letter: ' answer
*
* Read letter into variable answer.
*
Set prompt = 'Enter letter: '
Input prompt answer
InsLine -- Insert Line At Cursor InsLine -- Insert Line At Cursor
InsLine inserts a blank line in the display following the InsLine
line on which the cursor rests. All lines below the
inserted line (except the status line) are scrolled down,
and the last line is scrolled off the screen.
Key -- Set Function Key Values Key -- Set Function Key Values
Key reads function keys from a specified file, like the Key
<ALT>K keyboard entry "Read definitions from a file". The
syntax is:
Key Skeyfile
Skeyfile is the name of the file containing the keyboard Skeyfile
definitions.
Example:
In the following script segment:
*
* Read keyboard definition from file "mydefs.fnc"
*
Declare KeyFile String
*
Key "mydefs"
*
Set KeyFile = "mydefs"
Key KeyFile
*
Set KeyFile = "mydefs.fnc"
Key KeyFile
PibTerm Script Language Reference Guide Page 36 PibTerm Script Language Reference Guide Page 36
all three Key statements read key definitions from file Key
"mydefs.fnc" -- the ".fnc" is understood.
KeyDef -- Define Function Key Value KeyDef -- Define Function Key Value
KeyDef defines a string to be sent to the remote system when KeyDef
a function key is struck. This is like the <ALT>K "D)efine
key" command. The syntax is:
KeyDef Skeyname Skeytext
Skeyname is the name of the key to be defined. Skeyname
Skeytext is the text string to be assigned to the key. Skeytext
The following key names are used with KeyDef:
F1 through F12 (for function key F1 through F12) F1 F12
A1 through A12 (for <ALT>F1 though <ALT>F12); A1 A12
C1 through C12 (for <CTRL>F1 through <CTRL>F12); C1 C12
S1 through S12 (for <SHIFT>F1 through <SHIFT>F12). S1 S12
N1 through N0 (for <ALT>1 through <ALT>0 on top row N1 N0
of the keyboard);
N- (for <ALT>- on the top keyboard row) N-
N+ (for <ALT>+ on the top keyboard row) N+
K0 through K9 (for keypad 0 through 9) K0 K9
K. (for keypad . or DEL key) K.
K+ (for keypad + ) K+
K- (for keypad - ) K-
K* (for keypad * ) K*
K/ (for keypad / ) K/
KE (for keypad enter) KE
AK versions (for <ALT>keypad 0 through 9, etc.) AK
CK versions (for <CTRL>keypad 0 through 9, etc.) CK
PS (for PrtSc) PS
APS (for <ALT>PrtSc) APS
CPS (for <CTRL>PrtSc) CPS
AEN (for <ALT>Enter) AEN
BS (for Backspace) BS
CBS (for <CTRL>Backspace) CBS
ABS (for <ALT>BackSpace) ABS
XU (for separate cursor pad up arrow) XU
XD (for separate cursor pad down arrow) XD
XL (for separate cursor pad left arrow) XL
XR (for separate cursor pad right arrow) XR
PibTerm Script Language Reference Guide Page 37 PibTerm Script Language Reference Guide Page 37
AX versions (for <ALT>separate cursor pad keys) AX
CX versions (for <CTRL>separate cursor pad keys) CX
XI (for separate position pad Insert) XI
XH (for separate position pad Home) XH
XPU (for separate position pad PageUp) XPU
XDE (for separate position pad Delete) XDE
XE (for separate position pad End) XE
XPD (for separate position pad PageDown) XPD
AX versions (for <ALT>separate position pad keys) AX
CX versions (for <CTRL>separate position pad keys) CX
Not all keys exist on all keyboards. However, you can
always assign values to keys that don't exist on individual
keyboards anyway.
Examples:
*
Declare KeyName String
Declare KeyDef String
*
Key 'F1' 'DIR *.*|'
*
Set KeyName = 'F1'
Set KeyDef = 'DIR *.*|'
KeyDef Keyname KeyDef
KeyDef 'F1' Keydef
KeyDef KeyName 'DIR *.*|'
KeyFlush -- Flush Keyboard KeyFlush -- Flush Keyboard
KeyFlush flushes all pending characters from the keyboard. KeyFlush
KeySend -- Send Function Key Value To Remote KeySend -- Send Function Key Value To Remote
KeySend sends the specified key's definition to the remote KeySend
system. The syntax is:
KeySend Skeyname
Skeyname provides the name of the key to be sent. The Skeyname
allowed values for Skeyname are the same as for the KeyDef Skeyname KeyDef
command above.
Example:
* Send the text associated with function key F1
* to the remote system
*
KeySend "F1"
PibTerm Script Language Reference Guide Page 38 PibTerm Script Language Reference Guide Page 38
Log -- Toggle Printer Logging Log -- Toggle Printer Logging
Log toggles session logging on printer, like the keyboard Log
entry <ALT>L. You should ensure that your printer is turned
on before using <ALT>L. When logging is active, all the
output from the remote system is echoed on your printer.
Menu -- Display Pop-Up Menu Menu -- Display Pop-Up Menu
Menu displays a pop-up menu on the screen similar to those Menu
used internally by PibTerm. The syntax is:
MENU Ires Irow Icol Ideflt Stitle Sitem1 Sitem2 ...
Ires is the index of the menu item chosen (or -1 if the ESC Ires ESC
key it struck).
Irow and Icol indicate the position to display the top left- Irow and Icol
hand corner of the position menu. Irow and Icol may be Irow Icol
either integer variables or constants.
Ideflt is the index of the default choice and may be either Ideflt
an integer variable or constant.
Stitle is the menu title and may be either a string variable Stitle
or constant.
Sitem1, Sitem2, etc. provide the text for the menu line Sitem1, Sitem2
entries and may be either string variables or constants.
The resulting menu is displayed over the current contents of
the screen. The keypad arrow keys/mouse/first character of a
menu item can be used to choose a value from the menu, just
like with standard PibTerm menus.
Example:
Here is a menu definition which requests that a pop-up menu
with the title "Select baud rate" be placed at position
(column=10, row=11) on the screen. There are to be three
possible values, 300, 1200, and 2400. 2400 is to be
highlighted as the default value.
Declare MyBaud Integer
Menu MyBaud 10 11 3 "Select baud rate: " "300" "1200" "2400"
If the returned value of MyBaud is 1, then 300 was chosen;
if MyBaud is 2, then 1200 was chosen; if MyBaud is 3 then
2400 was chosen. If MyBaud is <= 0, then no choice was made
(the ESC key was hit).
PibTerm Script Language Reference Guide Page 39 PibTerm Script Language Reference Guide Page 39
Message -- Display Message On Screen Message -- Display Message On Screen
Message displays text on the screen. The syntax is: Message
Message String
where String is the text to be displayed. String may be String String
either a string variable or string constant.
The text is NOT sent to the remote system.
Example:
Message "Here is a sample message."
The message text cannot span more than a single line. You
may enter as many 'Message' statements in a row as you want,
if you wish to have more than one line of text appear.
There is an important difference in the function of Message Message
and Writeln 0. Message passes the characters through the Writeln 0 Message
current terminal emulator display mechanism, so that escape
sequences will be processed. This allows you to take
advantage of interesting effects possible when using escape
sequences. Writeln 0 writes the characters to the display Writeln 0
directly, without regard for the particular terminal
emulation begin used. Escape sequences will not be not
processed.
Mute -- Toggle Mute Mode Mute -- Toggle Mute Mode
Mute toggles mute mode, like the keyboard entry <ALT>M. In Mute
mute mode, no sounds like bells or music are issued. This
is ideal for those late-night sessions when you want to log
in to those remote systems that play the entire top 40 rock
hits before they allow you to do anything useful, and also
for those systems which beep at you every time you do
ANYTHING at all.
Open -- Open File Open -- Open File
Open make a text file accessible for processing in a script. Open
The syntax is:
Open Ifile Sname Stype
Ifile is the "handle" (1 through 10) to be assigned to the Ifile
file, and may be either an integer variable or constant.
Sname is the name of the file (which may include a complete Sname
DOS path).
PibTerm Script Language Reference Guide Page 40 PibTerm Script Language Reference Guide Page 40
Stype provides the access method for the file: Stype
'I' Input File to be read
'O' Output File to written/overwritten
'A' Append File to be added to at end of file
A file opened with OPEN should be closed with CLOSE. OPEN CLOSE
All opened files are automatically closed when the top
script level is exited. Files ARE global across nested
scripts.
A handle of 0 is reserved for keyboard/screen input/output.
You need not (and cannot) explicitly open handle 0.
To read from a file, use the script commands Read and Read
Readln. To write to a file, use Write and Writeln. See the Readln Write Writeln
definitions of those commands for details. To switch
between reading and writing a file, you need to CLOSE the CLOSE
file and re-open it.
Examples:
*
Declare handle integer
Declare filename string
Declare opentype string
*
Open 1 'bogus.txt' 'input'
*
Set handle = 2
Set filename = 'c:\mybogus\bogus2.txt'
Set opentype = 'output'
*
Open handle filename opentype
Param -- Set Program Parameter Param -- Set Program Parameter
Param sets Pibterm program parameters. The syntax follows Param
that used in the PIBTERM.CNF file. You specify the two-
letter name of the parameter to change, then an equal sign,
and then the value to be assigned to that parameter. The
parameter names and values are described in the "PibTerm
Parameters Reference Guide."
Param is an old script command, left over from previous Param
PibTerm versions, and included for compatibility. You
should use the SetParam command instead in new scripts. SetParam
For example, to change the terminal emulation to VT100 mode,
write:
Param te=3
PibTerm Script Language Reference Guide Page 41 PibTerm Script Language Reference Guide Page 41
To change the baud rate to 1200 baud, write:
Param ba=1200
PrintFile -- Print A File PrintFile -- Print A File
PrintFile starts printing a specified file using the built- PrintFile
in PibTerm print spooler. PibTerm overlaps the printing
with other duties like reading keyboard input or displaying
output received from the remote system.
The syntax for PrintFile is:
PrintFile Sname
Sname specifies the name of the file to be printed. Sname
To start printing a file called "BOGUSCO.LIS", write:
PrintFile "Bogusco.lis"
To stop the print operation before the file finishes
printing, write:
PrintFile ""
Procedure -- Define Script Procedure Procedure -- Define Script Procedure
Procedure marks the start of an internal script procedure. A Procedure
script procedure is like a script within a script. You can
declare an internal script procedure as follows:
PROCEDURE name args
-- statements ---
ENDPROC
Here name is the name of the procedure, and args is a list name args
of arguments and types for the procedure. A procedure may
reference any variables previously defined by higher level
procedures or the main script as well as the variables
defined by its arguments. Local variables -- declared within
the procedure -- are also allowed.
A procedure definition must precede its first use.
The EndProc acts as a return. You may also explicitly use EndProc
the Return statement. Return
You invoke a procedure using the CALL statement: CALL
Call name arguments
PibTerm Script Language Reference Guide Page 42 PibTerm Script Language Reference Guide Page 42
Here name is the name of the procedure, and arguments are name arguments
the procedure arguments. The arguments must match in type
and number with those declared on the PROCEDURE command PROCEDURE
defining the called procedure. (If not, a syntax error is
reported.) The arguments may be variables or constants, but
NOT expressions. Arguments which ARE variables may be
changed in the called procedures if desired. Constants will
NOT be changed, even if an assignment to the corresponding
procedure argument is made in the body of the procedure.
IT IS EXTREMELY IMPORTANT TO DECLARE ALL GLOBAL VARIABLES IT IS EXTREMELY IMPORTANT TO DECLARE ALL GLOBAL VARIABLES
BEFORE DEFINING ANY PROCEDURES, whether or not the BEFORE DEFINING ANY PROCEDURES,
procedures use variables. Likewise, all IMPORTs must precede
any procedure definitions.
Here is a sample script with two procedures, neither of
which takes an argument:
*
* Here is the first procedure.
*
PROCEDURE One
Message " "
Message "Script ONE was called."
Message " "
ENDPROC
*
* Here is the second procedure.
*
PROCEDURE Two
Message " "
Message "Script TWO was called."
Message " "
ENDPROC
*
* Begin "mainline" script. This is where script execution
* actually begins.
*
Call One
Call Two
Here is a sample script with procedures with sub-procedures
and arguments:
Declare A String
Declare B Integer
Declare S String
*
PROCEDURE Sub1 Mya String, MyB Integer
*
Declare MyC String
*
PROCEDURE Sub1a Mya String
Message "Entered procedure Sub1a"
PibTerm Script Language Reference Guide Page 43 PibTerm Script Language Reference Guide Page 43
Set MyC = CONCAT( CONCAT( 'Value of A = <', MyA ), '>' )
Message MyC
Set MyA = 'BOGUS A!!!!!'
ENDPROC
*
PROCEDURE Sub2a MyB Integer
Set MyC = CONCAT( 'Value of B = ', String( MyB ) )
Message MyC
ENDPROC
*
Call Sub1a Mya
Call Sub2a Myb
*
*
ENDPROC
*
PROCEDURE Sub2 MyB Integer
*
Declare MyC String
*
Message "Entered script Sub2"
Set MyC = CONCAT( 'Value of B = ', String( MyB ) )
Message MyC
*
Set MyB = 10
*
ENDPROC
*
PROCEDURE Sub3 MyA String
*
Declare MyC String
*
Message "Entered script Sub3"
Set MyC = CONCAT( CONCAT( 'Value of A = <', MyA ), '>' )
Message MyC
*
ENDPROC
*==============================================================
* M A I N P R O G R A M *
*==============================================================
*
Set A = 'Here is parameter A'
Set B = 50
*
Set S = CONCAT( CONCAT( 'A:<' , A ), '>' )
Message S
*
Set S = CONCAT( CONCAT( 'B:<' , STRING( B ) ), '>' )
Message S
*
Message A
Message "Calling procedure Sub1 ..."
*
Call sub1 A B
PibTerm Script Language Reference Guide Page 44 PibTerm Script Language Reference Guide Page 44
*
Message "Back to main"
Set S = CONCAT( CONCAT( 'New value of A is <', A ), '>' )
Message S
*
Message "Calling procedure Sub2 ..."
*
Call sub2 B
*
Message "Back to main"
Set S = CONCAT( 'New value of B is ', String( B ) )
Message S
*
Message "Calling procedure Sub3 ..."
*
Call sub3 A
*
Message "Back to main"
Procedure Sub1a above changes the value of MyA, which in Sub1a MyA
turn changes the value of variable A in the main script A
body. What if the call to Sub1 had been Sub1
Call sub1 'Hi there!' B
instead? Would the value of 'Hi there!' somehow be changed?
No, PibTerm recognizes that a request to change a constant
has been made and IGNORES it. The change WILL be in effect
during the lifetime of Sub1/Sub1a, but the changed value is
NOT passed back to the main script body.
Quit -- Quit PibTerm execution Quit -- Quit PibTerm execution
Quit terminates execution of PibTerm and returns to DOS. Quit
The effect of Quit is similar to typing <ALT>X, except that Quit
all current scripts are exited, and no prompt is issued
asking if execution should actually be terminated.
Quit is useful in writing scripts for unattended operation, Quit
so that PibTerm can be invoked as one command in a batch
file, and then the batch file can continue after PibTerm is
exited.
Read -- Read Characters From A File Read -- Read Characters From A File
Read reads characters from a file which has been opened with Read
the Open script command. The syntax is: Open
READ Ifile Sdata Ichars
PibTerm Script Language Reference Guide Page 45 PibTerm Script Language Reference Guide Page 45
Ifile is the file handle for the file from the Open command. Ifile
Ichars provides the number of characters to be read. Ichars
Sdata is the string of characters as read from the file. Sdata
Both Ifile and Ichars can be integer variables. Sdata must Ifile Ichars Sdata
be a string variable.
The file must have been opened for input; see the Open Open
command for details.
You can specify file handle 0 -- or omit the file handle
altogether -- to read from the keyboard.
You can test for end-of-file using the EOF function (see the EOF
description in the Set command). End-of-file is never Set
returned for the keyboard.
You can test for an I/O error using the IOResult function IOResult
(see the Set command for details). Set
Example:
Declare mychars string
* Open the file
Open 1 "myfile.dat" "I"
* Read ten characters from file
READ 1 mychars 10
* Check for an error
*
IF ( IOResult <> 0 ) THEN
Message "I/O error reading handle 1"
ENDIF
Another example:
Suppose you want to read one character from the keyboard
without requiring that a carriage return be entered
afterwards. That can be done by writing a read statement
for one character as follows:
*
Declare Ch String
*
Read Ch 1
Readln -- Read Line From File Readln -- Read Line From File
Readln reads a line of text from a file previously opened Readln
using the Open script command. The syntax is: Open
READLN Ifile Sdata
PibTerm Script Language Reference Guide Page 46 PibTerm Script Language Reference Guide Page 46
Ifile is the file handle to read from. Ifile
Sdata stores the characters read from the file, and must be Sdata
a string variable. If no characters are read, Sdata is Sdata
returned as an empty string.
A line is defined as a series of up to to 255 character,
terminated by Ascii characters ^M^J (carriage return and
line feed). The terminating ^M^J characters are not stored
as part of the string S1.
The file must have been opened for input; see the Open
command for details.
You can specify file handle 0 -- or omit the file handle
altogether -- to read from the keyboard.
You can test for end-of-file using the EOF function (see the EOF
description in the Set command). End-of-file is never Set
returned for the keyboard.
You can test for an I/O error using the IOResult function IOResult
(see the Set command for details). Set
Example:
Declare mychars string
* Open the file
Open 1 "myfile.dat" "I"
* Read line from file
READLN 1 mychars
* Check for an error
*
IF ( IOResult <> 0 ) THEN
Message "I/O error reading handle 1"
ENDIF
Receive -- Receive File From Remote System Receive -- Receive File From Remote System
Receive is used to receive a file from a remote system, like Receive
the keyboard command <ALT>R. The syntax is:
Receive Sname Sprotocol
Sname is the name of the file to be received. It may Sname
contain a wildcard specification for batch protocols.
Sprotocol contains the abbreviation for the protocol name to Sprotocol
be used for the transfer.
The protocol names are:
PibTerm Script Language Reference Guide Page 47 PibTerm Script Language Reference Guide Page 47
AS -- Ascii
XK -- Xmodem CheckSum
XC -- Xmodem CRC
X1 -- Xmodem 1K
XG -- Xmodem 1K G
YB -- Ymodem Batch
YG -- Ymodem G Batch
TE -- Telink
MK -- Modem7 Batch Checksum
M7 -- Modem7 Batch CRC
KE -- Kermit
If you have added any user-defined protocols, then their
abbreviations can also be used. For example, you
customarily use ZM as an abbreviation for Zmodem. ZM
To receive the file YUMYUM.PAS using Xmodem 1K, write:
Receive "yumyum.pas" "X1"
To receive a batch of files using Ymodem, write:
Receive "" "YB"
The file names are automatically provided by the sender with
Ymodem, so you don't have to specify the name -- just
provide a null filename as shown above. This is generally
true of other batch protocols as well.
Note that "Receive" only sets up PibTerm to receive a file
- it does NOT initiate a transfer from the remote system.
You will need to issue a command to the remote system to get
it to start a transfer so that Pibterm can receive the
file(s). For example, if you are connected to the file
section of an RBBS system, you might enter the following
sequence of statements to download a file you know you want:
*
* Request that file "goodstuf.lbr" be sent to me.
*
Stext "s;goodstuf.lbr;x|"
Receive "goodstuf.lbr" x
There are a number of remote Kermit server commands
implemented, available from the Kermit receive file menu.
You can also indicate that you want a remote server command
in a script, by requesting a Kermit download and using '/'
followed by the text of the remote server command.
Examples:
*
* Send FINISH command to server
PibTerm Script Language Reference Guide Page 48 PibTerm Script Language Reference Guide Page 48
*
Receive '/FINISH' "Ke"
*
* Send "display directory" command
*
Receive '/DIRECTORY' "Ke"
*
* Send "type file BOGUS" command
*
Receive '/TYPE BOGUS' "Ke"
*
* Send "change directory" command
*
Receive '/CWD Sys$login' "Ke"
It may seem backwards to use RECEIVE rather than SEND here,
but it turns out to be more convenient, since the output of
these commands is sent to PibTerm as file (to be displayed
on the screen) using the Kermit protocol.
Redial -- Redial Last Number Dialed Redial -- Redial Last Number Dialed
Redial redials the last phone number entered, like the Redial
keyboard command <ALT>Q. However, you can specify a phone
number in quotes on the 'Redial' command and PibTerm will
redial that phone number until a connection is established.
For example, to repeatedly dial phone directory entry 3
until a connection is established, write:
Redial "3"
Repeat -- Repeat Block Of Statements Repeat -- Repeat Block Of Statements
Repeat begins a block of statements to be repeatedly Repeat
executed until the condition on a matching UNTIL statement
is true.
Examples:
Here is a loop which sends a carriage return to the remote
system once every two seconds and looks to see if the string
"Username:" has arrived. The loop exits when "Username:" is
found.
Repeat
Stext '|'
Waitstring "Username:" 2
Until ( WaitFound )
Here is a "repeat forever" loop that will never complete:
PibTerm Script Language Reference Guide Page 49 PibTerm Script Language Reference Guide Page 49
Repeat
.
.
Until ( 0 )
You can stop such a loop from the keyboard by hitting
<ALT>X, or by using the Exit/ExitAll script commands inside Exit/ExitAll
the Repeat/Until loop.
Other testable conditions are described under the "If"
statement above.
Reset -- Reset Script Execute To Start Of Script Reset -- Reset Script Execute To Start Of Script
Reset starts executing the current script from the beginning Reset
of the script again. Reset has no arguments.
RInput -- Receive Input From Remote System RInput -- Receive Input From Remote System
RInput prompts for input from the remote system. The syntax RInput
is:
RInput Sprompt Secho Sanswer
Sprompt is the prompt string, which will be sent to the Sprompt
remote system as an indication that input is being
requested. The prompt string can be empty, in which case no
prompt to the remote system will be issued.
Secho indicates if the remote system's response characters Secho
are to be echoed by the actual character value or a '.' for
security purposes.
Sanswer is the response from the remote system, and must be Sanswer
specified as a string variable.
Setting Sechor = 'Echo' causes the actual character values Sechor
received from the remote system to be echoed. Setting Secho Secho
= 'Noecho' causes '.' to be used to echo each character.
This is useful when echoing passwords.
Examples:
PibTerm Script Language Reference Guide Page 50 PibTerm Script Language Reference Guide Page 50
* Read response from remote system into
* variable, echoing the characters as
* sent.
Declare Response String
Declare Prompt String
Declare Echo String
*
RInput 'Enter letter: ' 'ECHO' Response
*
* Now read response and echo using '.'s.
*
Set Prompt = 'Enter letter: '
Set Echo = 'NOECHO'
RInput Prompt Echo Response
ScreenDump -- Dump Screen To File ScreenDump -- Dump Screen To File
ScreenDump writes the current screen contents (text only) to ScreenDump
a file, like the <ALT>U keyboard command. The syntax is:
SCREENDUMP Sname
Sname contains the file name to receive the screen dump. Sname
Examples:
Declare DumpFile String
ScreenDump 'bozo.dat'
Set DumpFile = 'bozo.dat'
ScreenDump DumpFile
Send -- Send File To Remote System Send -- Send File To Remote System
Send sends a file to a remote system, like the keyboard Send
command <ALT>S. The syntax is:
Send Sname Sprotocol
Sname is the name of the file to be sent, and can be a Sname
wildcard specification for batch protocol transfers.
Sprotocol is the protocol abbreviation. (See the Receive Sprotocol Receive
command for a list of protocol abbreviations.)
For example, to send the file "yumyum.lbr" to a remote
system using Xmodem-CRC, write:
Send "yumyum.lbr" "xc"
To send all files ending in .PAS using Telink to a remote
system, write:
PibTerm Script Language Reference Guide Page 51 PibTerm Script Language Reference Guide Page 51
Send "*.pas" "te"
'Send' only causes PibTerm to begin sending files to the
remote system. You must have previously instructed the
remote system to be ready to receive the files. For
example, if you are connected to the file section of an RBBS
system, you could send the file "yumyum.lbr" using Xmodem
with the commands:
SText "r;yumyum.lbr;x|"
Suspend 400
Send "yumyum.lbr" "x"
The Suspend is included to ensure we don't start the send Suspend
procedure before RBBS is ready.
Kermit transfers are particularly easy if the remote system
can run Kermit in server mode. Just run Kermit on the
remote system, put it into server mode, and issue Send
commands to your heart's content. For example, to send a
bunch of files to a Vax system running Kermit under VMS, you
could write:
*
* Wait for VMS command prompt
*
WaitString "$"
*
* Start up Kermit
*
SText "Kermit|"
*
* Wait for Kermit's prompt, then send command
* to put Kermit in server mode.
*
Waitstring ">"
SText "Server|"
*
* Wait for blurb about server mode to go by, then
* send a bunch of files, then receive a file.
*
Suspend 500
Send "*.pas" "ke"
Send "*.doc" "ke"
*
Receive "newstuf.doc" "ke"
*
* Take remote Kermit out of server mode.
*
Receive "/finish" "ke"
*
* Tell remote Kermit to stop executing.
*
PibTerm Script Language Reference Guide Page 52 PibTerm Script Language Reference Guide Page 52
SText "exit|"
Set -- Assign Value To Script Variable Set -- Assign Value To Script Variable
The Set command may be used to assign values to script Set
variables. The Set command has the form:
Set varname = expression
where 'varname' is the name of the variable to be set, and
'expression' is the value.
You may omit Set if you like, since a script line of the Set
form
varname = expression
is assumed to be a Set statement. Set
The allowable expressions are:
1. a string constant enclosed in quotes for a string
variable, e.g.,
SET Abc = 'Here''s a string'
2. an integer constant for an integer variable, e.g.,
SET c = 123
3. another variable
SET Abc = Yum
4. a special function, which may be one of the following:
ATTENDED returns a value of 1 if the session ATTENDED
is in attended mode (AM=1) or 0 if
the session is in unattended mode
(AM=0).
CHR( n ) returns a 1-character string CHR( n )
containing the Ascii character
whose ordinal is given by 'n'. For
example, CHR(65) = 'A'. If 'n' is
not in the range 0 through 255,
then a null string is returned.
CONCAT( s1 , s2 ) concatenates strings 's1' and 's2'. CONCAT( s1 , s2 )
PibTerm Script Language Reference Guide Page 53 PibTerm Script Language Reference Guide Page 53
CONNECTED returns a value of 1 if a remote CONNECTED
connection has been made or 0 if a
remote connection doesn't exist.
DUPL( S1, n ) returns string with first character DUPL( S1, n )
in S1 duplicated n times.
DATE returns date as a string in DATE
YY/MM/DD format.
DIALED returns the dialing entry number if DIALED
this script was executed because it
was attached to a dialing directory
entry, or 0 (or -1) otherwise.
DIALENTRY( n ) returns the n-th dialing directory DIALENTRY( n )
entry as a string. This string can
be broken up into fields using
other string functions. The format
of the dialing directory is
described in the PibTerm parameter
reference guide. If an invalid
entry number is given, a null
string is returned.
ENHKEYBD returns 1 if an enhanced 101-key ENHKEYBD
keyboard is in use, 0 otherwise.
EOF( I1 ) returns 1 if file attached to EOF( I1 )
handle specified by I1 is at end of
file, 0 otherwise. (See the
description below of the OPEN
script command for details.)
FILEEXISTS( S1 ) returns a value of 1 if the file FILEEXISTS( S1 )
named in 'S1' exists, or '0' if it
doesn't exist.
INDEX( s1 , s2 ) position of string 's1' in string INDEX( s1 , s2 )
's2' or zero if not found
IORESULT returns system code from last I/O IORESULT
operation. Should be used
following READ, WRITE, OPEN, etc.
commands to check whether operation
proceeded properly. 0 always means
operation completely successfully.
KEYSTRING( s ) returns the function key string KEYSTRING( s )
attached to the key name specified
by the value of "s". See the
description of the KeyDef script
command for legitimate names to use
in "s".
PibTerm Script Language Reference Guide Page 54 PibTerm Script Language Reference Guide Page 54
LENGTH( s ) current length of string variable LENGTH( s )
's'.
LTRIM( S1 ) trims leading blanks from string LTRIM( S1 )
S1.
NUMBER( s1 , n ) if 's1' can be converted to NUMBER( s1 , n )
integer, then the integer value,
else zero. If the conversion was
done, N is 0, else N is the
character position in 's1' which
caused the conversion to fail.
ORD( s1, n ) returns the Ascii ordinal of the ORD( s1, n )
nth character in the string s1.
For example, ORD( 'A', 1 ) returns
65. If 'n' is less than 1 or
greater than the length of 's1', 0
is returned.
PARAMLINE returns current parameter line PARAMLINE
contents (for use when executing
script tied to added user command).
PARAMCOUNT returns number of blank-delimited PARAMCOUNT
parameters appearing in current
parameter line (as given by
PARAMLINE).
PARAMSTR( I1 ) returns I1-th parameter in current PARAMSTR( I1 )
parameter line (as given by
PARAMLINE).
READCTRL( s1 ) reads a string containing the READCTRL( s1 )
special control character markers
used for function key definitions,
with each instance of the marked
characters converted to actual
control characters. For example,
"ReadCtrl( ^C )" where "^C" are the
two ascii characters with ordinals
94 and 67, is converted to the
single control character ^C with ^C
ascii ordinal 3.
STRING( n ) value of integer constant or STRING( n )
variable 'n' converted to string
SUBSTR( s1, b, l ) substring of 's1' for length 'l', SUBSTR( s1, b, l )
starting at position 'n'.
TIME returns time of day as a string in TIME
24 hour HH:MM:SS format.
PibTerm Script Language Reference Guide Page 55 PibTerm Script Language Reference Guide Page 55
TRIM( S1 ) trims trailing blanks from string TRIM( S1 )
S1.
UPPERCASE( S1 ) returns contents of S1 after UPPERCASE( S1 )
converting lower-case to upper
case.
WAITFOUND returns 1 if preceding WAITSTRING WAITFOUND
or WAITLIST was successful, else
returns 0.
WRITECTRL( s1 ) returns a string in which any WRITECTRL( s1 )
instances in 's1' of control
characters are converted to '^'
prefix form, etc.
5. A complex expression containing variables, constants,
operators, parentheses, and function calls.
Note that no SET statement can exceed one input line. You
can break up complicated expressions into a series of SET
statements if you need to.
A short example:
DECLARE a String
DECLARE b String
DECLARE c Integer
DECLARE d Integer
SET a = 'HERE IS A LINE OF TEXT WITH 123 in it'
SET d = POS( '1' , a )
SET b = Substr( a, d, 3 )
SET c = NUMBER( b , d )
At this point, the value of 'c' is 123.
The last four lines could also be written:
SET a = 'HERE IS A LINE OF TEXT WITH 123 in it'
SET c = NUMBER( Substr( a, d, 3 ) , POS( '1' , a ) )
Here is a more complicated arithmetic assignment:
SET c = ( ( c * 24 ) / D ) + 13
SetParam -- Set Value Of PibTerm Parameter SetParam -- Set Value Of PibTerm Parameter
SetParam sets a PibTerm parameter to a specified value. The
syntax is:
SetParam Spname Spval
PibTerm Script Language Reference Guide Page 56 PibTerm Script Language Reference Guide Page 56
Spname is the name of the parameter. Spname
Spval is the new parameter value. Spval
If a PibTerm parameter is of boolean type, enter "1" to set
the parameter value to True, or enter "0" to set the value
to False. (See the "Parameter Language Reference Manual" to
determine the type for each PibTerm parameter.)
To increase the efficiency of processing several SetParam
statements, try to place them one right after the other if
possible. This avoids extra code module swaps during script
execution.
Examples:
Declare Name String
Declare Rate String
Declare True String
* Set terminal type to VT100
SetParam "te" "3"
* Change baud rate to 1200
Set Rate = "1200"
Set Name = "ba"
SetParam name rate
*
* Set hardwired mode
*
Set True = "1"
SetParam "hw" True
SetVar -- Set Value of PibTerm Parameter SetVar -- Set Value of PibTerm Parameter
SetVar sets the most recent instantiation of a script SetVar
variable to a specified value. The syntax is:
SETVAR Svname Sval
Svname provides the name of the variable to be set. Svname
Sval is the new value for the variable. Sval
SetVar has a different purpose than the Set command. The Set
Set command is translated into internal code at the time a
script is compiled. You cannot therefore use Set to
reference a variable whose name you don't know until the
script is being executed. With SetVar, you can assign a
value to a variable whose name you don't know until the
execution time of the script. Note that SetVar is MUCH
slower than using a Set command; use Set if possible. Also,
PibTerm Script Language Reference Guide Page 57 PibTerm Script Language Reference Guide Page 57
SetVar doesn't allow an expression as a value, although this
isn't a real problem: you can use a Set command to build the
value of the Sval parameter to SetVar. Sval
Examples:
Declare vtype string
Declare vval string
Declare vname string
Declare I Integer
...
SetVar 'VARA' 'Hi there'
SET vname = 'VARA'
SET vval = 'Hi there'
SetVar vname vval
SetVar 'I' '10'
SText -- Send Text To Remote System SText -- Send Text To Remote System
SText sends text to the remote system. The syntax is: SText
SText String
String contains the text to be sent. String
The special characters used in function keys for carriage
returns, marking control characters, and delays may be used
in SText as well. (See the section on the <ALT>K keyboard
command in the PibTerm Guide for details on these special
characters.)
You've already seen a number of examples of SText in action
in the description of other commands.
Suspend -- Suspend Execution Of Script Suspend -- Suspend Execution Of Script
Suspend suspends script execution for a given length of time Suspend
(PibTerm continues executing). The syntax is:
Suspend Itime
Itime is the length of time in hundredths of a second to Itime
suspend the script execution.
For example, to stop script processing for one second,
enter:
Suspend 100
To stop script processing for half a second, enter:
Suspend 50
PibTerm Script Language Reference Guide Page 58 PibTerm Script Language Reference Guide Page 58
Suspend differs from the Delay script command in that Delay Delay
stops EVERYTHING except the reception of remote characters,
while Suspend only stops the execution of script commands.
Note, however, that WaitString and When searches will
continue during the suspension period. That makes Suspend
useful in writing conditional loops with recalcitrant remote
systems that may require a variable number of, say, carriage
returns before the remote system wakes up.
Text -- Send Text To Remote System Text -- Send Text To Remote System
Text sends text to the remote system, WITHOUT any special Text
interpretation (e.g., unlike SText). The syntax is:
Text String
String provides the text to be sent. No special processing String
is performed on the text, unlike the SText command.
Translate -- Read In Translate Table Translate -- Read In Translate Table
Translate reads in a translation table from a file, just Translate
like the "read file" option of <ALT>T. The syntax is:
Translate Sname
Sname is the file name from which to read the translation Sname
table.
For example, to read a table from the file "Striphi.tra",
write:
Translate "striphi"
The ".tra" is assumed.
Until -- End Repeat Block Until -- End Repeat Block
See the Repeat statement above. Repeat
ViewFile -- Invoke File Viewer ViewFile -- Invoke File Viewer
ViewFile invokes the file viewer specified by the LN=
parameter. If the value of LN= is null, then the built-in
PibTerm file viewer is invoked. Otherwise, the string
specified as the value of LN= is executed as a DOS command,
after making any required file name substitution (see the
PibTerm Script Language Reference Guide Page 59 PibTerm Script Language Reference Guide Page 59
description of the LN= parameter in the "PibTerm Parameter
Reference Manual" for details).
The syntax of ViewFile is:
ViewFile Sname
Sname specifies the name of the file to be viewed. Sname
For example, to invoke the viewer for the file
"BOGUSCO.DAT", you could write:
ViewFile "Bogusco.dat"
Wait -- Wait For Time Of Day Wait -- Wait For Time Of Day
Wait stops PibTerm execution until a given time (in HH:MM:SS Wait
form) is reached, at which time execution proceeds. The
syntax is:
Wait Stime
Stime provides the time to wait for in HH:MM:SS format.
For example, to stop PibTerm execution until 1 AM, write:
Wait "01:00:00"
The wait command only works within a given 24 hour period.
WaitCount -- Wait For Number Of Characters WaitCount -- Wait For Number Of Characters
WaitCount causes PibTerm to wait until a specified count of
characters has arrived from the remote system, regardless of
what characters they are. The syntax is:
WAITCOUNT Icount
Icount is the number of characters to wait for. Icount
Note that NUL characters (Ascii 0) are NOT counted if NUL
received.
Example:
PibTerm Script Language Reference Guide Page 60 PibTerm Script Language Reference Guide Page 60
* Wait for 5 characters to be received
Declare count integer
*
Set count = 5
*
WaitCount 5
WaitCount count
WaitList -- Wait For List Of Strings WaitList -- Wait For List Of Strings
WaitList waits for any of up to twenty strings to appear WaitList
from the remote system. The syntax is:
WaitList Index Swait1 Swait2 Swait3 ...
Index is the index of the string found. Index must be an Index Index
integer variable. If none of the strings is found, then
Index is returned as 0. Index
Swait1, Swait2, etc. are the strings to be waited for. I Swait1, Swait2
must be an integer variable.
If Index is returned as 0, then none of the strings was Index
found in the wait time. The wait time is set using the
WaitTime command (which see). WaitTime
The WaitFound function (see the Set command) can also be WaitFound Set
used to determine if any of the strings was found, but it
doesn't indicate which.
WaitList is similar to WaitString, but WaitString only WaitString
allows one string to be waited on. However, WaitString
executes faster than a WaitList with one string specified.
Example:
Declare Index Integer
Declare Str1 'CONNECT'
Declare Str2 'NO CARRIER'
Declare Str3 'BUSY'
WaitList Index Str1 Str2 Str3 'VOICE'
IF ( Index > 0 ) THEN
*
* process string found
*
...
ELSE
*
* process string not found
*
...
ENDIF
PibTerm Script Language Reference Guide Page 61 PibTerm Script Language Reference Guide Page 61
WaitQuiet -- Wait For Quiet Line WaitQuiet -- Wait For Quiet Line
WaitQuiet waits until the communications line has been
"quiet" -- no characters have been received -- for a
specified length of time. The syntax is:
WAITQUIET Itime
Itime specifies the number of tenths of a second to wait for Itime
the communications line to be quiet.
Example:
* Wait for 1/2 (5/10) second for quiet line
*
Declare Time Integer
*
Set Time = 5
*
WaitQuiet 5
WaitQuiet Time
WaitString -- Wait For String From Remote WaitString -- Wait For String From Remote
WaitString causes Pibterm to wait for a given string to WaitString
appear from the remote system. The syntax is:
WaitString Swait Itime
Swait is the string to be waited on. Swait
Itime is the number of seconds to wait for the string to Itime
appear. If Itime is not specified, then the current wait Itime
time is whatever was specified by a preceding WaitTime WaitTime
command. If no previous WaitTime command was given, then a
wait time of 30 seconds is used.
If the string does not appear within the specified time
period, then execution proceeds with the next script
command. WaitString can be combined with the Repeat/Until,
While/EndWhile, and If/Else/Endif script statements to good
effect, since the WaitFound (see the Set command) condition WaitFound Set
is TRUE (=1) if the specified string appeared, and FALSE
(=0) if it didn't appear.
To wait until the string 'Username:' appears, write:
WaitString 'Username:'
PibTerm waits 30 seconds for 'Username:' to appear. If you
want it to wait for, say 60 seconds, write:
PibTerm Script Language Reference Guide Page 62 PibTerm Script Language Reference Guide Page 62
WaitString 'Username:' 60
You can wait for a single character:
WaitString ">"
WaitString slows down PibTerm's execution somewhat, so you WaitString
should not be surprised if the output from the remote system
is displayed more slowly than usual.
WaitTime -- Set Wait Time WaitTime -- Set Wait Time
WaitTime specifies the time allotted for successful WaitTime
completion of a WaitString or WaitList command. (For an
individual WaitString, this time can be overridden on the
WaitString command itself.) The syntax is:
WAITTIME Itime
Itime is the time in seconds to wait. 30 seconds is the Itime
default wait time.
Examples:
Declare waiting Integer
WaitTime 25
Set waiting = 40
WaitTime waiting
When -- Wait For String And Respond When -- Wait For String And Respond
When waits for a given string to appear from the remote When
system -- like WaitString -- and then sends a specified
response string. The syntax is:
When Swait Ssend
Swait is the string to wait for, and Ssend is the response Swait Ssend
string. Both may be either string constants or string
variables.
When searching stays active until you deactivate it using When
<ALT>X, even after the script itself has finished executing.
Hence, to stop a script, you can enter <ALT>X, but the WHEN
keeps on going. You can enter another <ALT>X to stop the
WHEN. A third <ALT>X takes you out of PibTerm entirely.
When slows down PibTerm's execution somewhat, so you should When
not be surprised if the output from the remote system seems
to be displayed more slowly than usual.
PibTerm Script Language Reference Guide Page 63 PibTerm Script Language Reference Guide Page 63
Examples:
Declare Whenwait String
Declare Whensend String
*
WHEN 'Username: ' 'MYUSERID|'
*
Set Whenwait = 'Username: '
Set Whensend = 'MYUSERID|'
*
WHEN Whenwait Whensend
WhenDrop -- Take Action On Carrier Drop WhenDrop -- Take Action On Carrier Drop
WhenDrop specifies a string to be sent to the modem when a WhenDrop
carrier drop is detected. The syntax is:
WHENDROP Ssend
Ssend is the string to be sent out the port to the modem Ssend
when the carrier drops.
WhenDrop is useful for resetting a modem when a carrier drop
occurs. Since Ssend may contain an Execute PibTerm command Ssend Execute
function, this allows you to deal with many conditions on a
carrier drop. This WhenDrop condition can co-exist with an
ordinary When condition. When
Example:
WhenDrop "@G@/WEDIED^M/"
This says that when the carrier drop occurs, PibTerm is to
execute the script "WEDIED.SCR". (@G --> <ALT>G, @/WEDIED^M/
--> WEDIED followed by CHR(CR), so script WEDIED is
executed.)
WhereXY -- Return Current Cursor Position WhereXY -- Return Current Cursor Position
WhereXY returns the current row and column position of the WhereXY
cursor on the screen. The syntax is:
WhereXY Icolumn Irow
Icolumn receives the column position and Irow receives the Icolumn Irow
row position. Both must be integer variables.
PibTerm Script Language Reference Guide Page 64 PibTerm Script Language Reference Guide Page 64
While -- Execute Statements While Condition True While -- Execute Statements While Condition True
While begins a block of statements to be repeatedly executed While
as long as the specified condition on the While statement is
true. A While block is terminated by an EndWhile statement. EndWhile
The form of the condition for the While statement is
identical to that for the Until and If statements. Until If
For example, to execute a block of script statements as long
as PibTerm is connected to a remote system, write:
While ( Connected ) Do
.
.
.
EndWhile
See the Set statement for details on Connected, and the If Set Connected If
statement for details on conditions.
Write -- Write Characters To File Write -- Write Characters To File
Write writes characters to a file prepared by the Open Write Open
command. The syntax is:
WRITE Ifile Sdata
where Ifile is the file handle of the file, and Sdata is the Ifile Sdata
string of characters to be written.
A handle of 0 refers to the screen. A missing file handle
also refers to the screen.
You can use the IOResult function to check for errors (see IOResult
the Set command). Set
Examples:
Declare handle integer
Declare HiString String
*
Open 1 "bogusco.dat" "O"
*
WRITE 1 'Hi there!'
*
Set HiString = 'Hi there!'
Set handle = 1
*
WRITE handle HiString
PibTerm Script Language Reference Guide Page 65 PibTerm Script Language Reference Guide Page 65
Writeln -- Write Line To File Writeln -- Write Line To File
Writeln writes a string to a file, terminated by a carriage Writeln
return and linefeed. The syntax is:
WRITELN Ifile Sdata
Ifile is the file handle and Sdata is the string to be Ifile Sdata
written. Ifile may be either an integer or an integer Ifile
constant. Sdata may be either a string or a string Sdata
constant. Sdata should NOT have the ^M^J (carriage return- Sdata
linefeed) specified as part of the string; those are added
automatically.
A file handle of 0 refers to the screen. A missing file
handle also refers to the screen.
Examples:
Declare handle integer
Declare HiString String
*
WRITELN 1 'Hi there!'
*
Set HiString = 'Hi there!'
Set handle = 1
*
WRITELN handle HiString
*
WRITELN 0 'This appears on screen.'
WRITELN 'This also appears on screen.'
WriteLog -- Write String To Log Files WriteLog -- Write String To Log Files
WriteLog writes the contents of a string to all of the WriteLog
active log files. These include the review buffer, the
capture file, the PIBTERM.LOG log file, and the printer --
whichever are in use (if any). The string is written
preceded by the current date and time in standard PibTerm
logging format.
The syntax is:
WRITELOG Slog
Slog is the string to be written. Slog can be either a Slog Slog
string variable or a string constant.
Using Script Commands in Command Line Mode Using Script Commands in Command Line Mode
You can enter a script command from the keyboard. This
allows you to use PibTerm in a command-driven fashion if you
PibTerm Script Language Reference Guide Page 66 PibTerm Script Language Reference Guide Page 66
dislike the menus. To do this you need to define a key
which will invoke command mode. This is done at the <ALT>P,
O)dds and ends, b) command key definition submenu. You will
be asked to hit the key which will be subsequently used to
invoke command mode. This key must be one of those
available for definition at <ALT>K.
There is NO DEFAULT value for the command line key, i.e.,
PibTerm does not provide command line mode by default.
Hitting the command key causes the status line (usually line
25) of the display to show 'Command: '. You may then enter
a script command which will be immediately executed.
For example, you might enter the command
Dial "1"
to dial the first number in the dialing directory, or
SetParam "pa" "N"
to set no parity.
If the command is incorrectly entered, an error message is
printed on the status line.
You may add your own user-defined commands. See the
description of the AddCommand script command above for AddCommand
details.
Script Commands Legal In Command Line Mode Script Commands Legal In Command Line Mode
The following subset of script commands can be used sensibly
in command line mode:
Addlf Alarm Break Capture ChDir
Clear ComDrain ComFlush CopyFile Delay
Dial Dos Echo EditFile EraseFile
Execute Exit ExitAll FreeSpace GetDir
GetParam Hangup Host Input Key
KeyDef KeyFlush KeySend Log Message
Mute Param PrintFile Quit Receive
Redial RInput ScreenDump Send
SetParam SText Suspend Text Translate
ViewFile Wait WaitCount WaitList WaitQuiet
WaitString WaitTime When WhenDrop
WriteLog
Some of the other commands may be accepted, but aren't
probably useful in command line mode. Some of the commands
(like IF, REPEAT, etc.) will NOT be accepted at all.
PibTerm Script Language Reference Guide Page 67 PibTerm Script Language Reference Guide Page 67
Sample Scripts Sample Scripts
The script language in PibTerm is complicated enough that
some extended examples are useful in showing how scripts can
be constructed for common login sequences. You can also
find some script examples in the "Guide to Using PibTerm."
There are also a number of sample scripts (including those
shown here) provided as part of the PibTerm release
materials (look for the files ending in ".SCR").
Notice how similar all of the login scripts are. You should
be able to modify one of these (or one of the others
provided as part of the PibTerm release materials) for
nearly any type of mainframe, mini, or remote bulletin board
system you wish to access.
CDC/NOS login script CDC/NOS login script
Here is a script for automatically logging on to the CDC NOS
mainframe system at ACNS. Other CDC sites will generally
require a different sequence:
***************************************************************************
* N O S . S C R --- Script for connecting to Cyber NOS system *
***************************************************************************
* *
* Script: Nos.Scr *
* *
* Purpose: Connects to Cyber NOS system. Designed for use as *
* attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "Nos" *
* *
* Remarks: *
* *
* Change the values of "username" and "password" to those of *
* your own NOS account. *
* *
***************************************************************************
*
* Send CRs to wake up autobaud
Repeat
*
SText "|"
* Wait on parity message, indicating
* baud rate/parity detected
WaitString "arity" 4
*
PibTerm Script Language Reference Guide Page 68 PibTerm Script Language Reference Guide Page 68
Until ( WaitFound OR ( NOT Connected ) )
*
* If carrier dropped, quit script.
If ( NOT Connected ) Then
Exit
Endif
* Now wait for "operating system" prompt
WaitString "ting system"
* If carrier dropped, quit script.
If ( NOT Connected ) Then
Exit
Endif
* Indicate to CDCNET that we want
* a NOS session. For NOS/VE, we
* would send "CREC VE" instead.
WaitQuiet 20
SText "crec nos|"
* Wait for username prompt
WaitString "USER NAME:"
* Send user name -- ENTER YOURS HERE.
SText "username|"
* Wait for password prompt
WaitString "PASSWORD:"
* Send password -- ENTER YOURS HERE.
SText "password|"
* Wait for bulletins, etc. to pass.
WaitQuiet 30
* Set VT100 emulation in PibTerm.
SetParam 'VC' '0'
SetParam 'AK' '0'
* Load NOS function keys.
Key 'cdcnos.fnc'
* Set backspace if not already set.
SetParam 'BS' '^H'
SetParam 'DE' ''
* Set VT100 emulation on NOS.
SText "SETTERM,VT100|"
VAX/VMS login script VAX/VMS login script
Here is a script to log on to a Vax system running under
VMS, like the Vax 785 at ACNS:
***************************************************************************
* V A X . S C R --- Script for connecting to Vax VMS system *
***************************************************************************
* *
* Script: Vax.Scr *
* *
* Purpose: Connects to Vax VMS system. Designed for use as *
* attached script in dialing directory. *
* *
PibTerm Script Language Reference Guide Page 69 PibTerm Script Language Reference Guide Page 69
* Invocation: *
* *
* Execute "Vax" *
* *
* Remarks: *
* *
* Change the values of "username" and "password" to those of *
* your own Vax account. *
* *
***************************************************************************
*
* Wake up Vax's autobaud.
Repeat
*
SText "|"
* Wait for "Username" prompt.
WaitString "Username:" 2
*
UNTIL ( WaitFound OR ( NOT Connected ) )
*
* Quit if carrier dropped.
IF ( NOT Connected ) THEN
Exit
ENDIF
* Send user name -- PUT YOURS HERE.
SText "username|"
* Wait for password prompt.
WaitString "Password:"
* Send password -- PUT YOURS HERE.
SText "password|"
*
* Set VT100 emulation
SetParam 'VC' '0'
SetParam 'AK' '0'
*
WaitString "$ "
SText "SET TERM/VT100|"
* Load Vax function keys
IF ( EnhKeybd = 1 ) THEN
Key 'decvaxe.fnc'
ELSE
Key 'decvax.fnc'
ENDIF
* Set backspace if not already set.
SetParam 'DE' '^H'
SetParam 'BS' ''
IBM CMS login script IBM CMS login script
Here is a script to log on to an IBM CMS system, through an
7171 (or equivalent) front-end:
PibTerm Script Language Reference Guide Page 70 PibTerm Script Language Reference Guide Page 70
***************************************************************************
* I B M . S C R --- Script for connecting to IBM CMS system *
***************************************************************************
* *
* Script: Ibm.Scr *
* *
* Purpose: Connects to IBM CMS system with a 7171 front end. *
* Designed for use as attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "Ibm" *
* *
* Remarks: *
* *
* Change the values of "username" and "password" to those of *
* your own Ibm account. *
* *
***************************************************************************
*
* Wake up 7171 front-end
Repeat
*
SText "|"
* Wait for "Username" prompt.
WaitString "TYPE:" 2
*
Until ( WaitFound OR ( NOT Connected ) )
*
* Quit if carrier dropped.
IF ( NOT Connected ) THEN
Exit
ENDIF
* Send terminal type of VT100
SText "vt100|"
* Set VT100 emulation in PibTerm
SetParam 'VC' '0'
SetParam 'AK' '0'
* Load CMS function keys
IF ( EnhKeybd = 1 ) THEN
Key 'ibmcmse.fnc'
ELSE
Key 'ibmcms.fnc'
ENDIF
* Load backspace if not already done
SetParam 'BS' '^[[OD'
SetParam 'DE' '^[[OD'
* Wait for intro screen to finish.
WaitQuiet 30
* Issue login -- put your own account
* and password here.
*
SText "|"
WaitQuiet 10
PibTerm Script Language Reference Guide Page 71 PibTerm Script Language Reference Guide Page 71
*
SText "login username password|"
*
LUIS login script LUIS login script
Here is a script for logging in to the LUIS system. LUIS
runs under IBM CMS, but there is no account and password
required.
***************************************************************************
* L U I S . S C R --- Script for connecting to Luis system *
***************************************************************************
* *
* Script: Luis.Scr *
* *
* Purpose: Connects to Luis system. Designed for use as *
* attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "Luis" *
* *
***************************************************************************
*
* Wake up protocol converter.
Repeat
*
SText "|"
* Wait for "Username" prompt.
WaitString "TYPE:" 2
*
UNTIL ( WaitFound OR ( NOT Connected ) )
*
* Quit if carrier dropped.
IF ( NOT Connected ) THEN
Exit
ENDIF
* Send terminal type of VT100.
SText "vt100|"
* Wait until an intro stuff clears.
WaitQuiet 20
* Send CR to get Luis screen.
SText "|"
*
* Set VT100 emulation
SetParam 'VC' '0'
SetParam 'AK' '0'
* Load CMS function keys
SetParam 'BS' '^[[OD'
SetParam 'DE' '^[[OD'
*
PibTerm Script Language Reference Guide Page 72 PibTerm Script Language Reference Guide Page 72
IF ( EnhKeybd = 1 ) THEN
Key 'ibmcmse.fnc'
ELSE
Key 'ibmcms.fnc'
ENDIF
*
OPUS login script OPUS login script
Here is a script to log on to an OPUS system. This is the
bulletin board software currently running on the
Northwestern IBM PC bulletin board system.
***************************************************************************
* O P U S . S C R --- Script for logging into OPUS BBS system *
***************************************************************************
* *
* Script: Opus.Scr *
* *
* Purpose: Connects to OPUS system. Designed for use as *
* attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "Opus" *
* *
* Remarks: *
* *
* Change the values of "firstname", "lastname", and "password" *
* to those of your own OPUS account. *
* *
***************************************************************************
*
* Wait for name prompt.
Waitstring "Your FIRST name:" 2
* Carrier dropped -- quit.
If ( NOT Connected ) Then
Exit
EndIf
* Didn't get "FIRST name" prompt -- quit.
If ( NOT WaitFound ) Then
Exit
Endif
*
* Send first name, last name.
* PUT YOURS HERE.
*
SText "firstname lastname|"
*
* Reply "y" to validation prompt
*
Waitstring "Y,n"
PibTerm Script Language Reference Guide Page 73 PibTerm Script Language Reference Guide Page 73
Stext "y|"
*
* Wait for password prompt and then
* send password.
* PUT YOURS HERE.
*
Waitstring "assword:"
Stext "password|"
RBBS login script RBBS login script
Here is a script to log on to an RBBS system. This script
may need modification for an individual RBBS system, since
there can be a great deal of variation as regards initial
welcome messages and so on.
***************************************************************************
* R B B S . S C R --- Script for logging into RBBS BBS system *
***************************************************************************
* *
* Script: Rbbs.Scr *
* *
* Purpose: Connects to RBBS system. Designed for use as *
* attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "Rbbs" *
* *
* Remarks: *
* *
* Change the values of "firstname", "lastname", and "password" *
* to those of your own RBBS account. *
* *
***************************************************************************
*
* Wait for name prompt.
WaitString "ame:"
* Send first name, last name, and password.
* PUT YOURS HERE.
*
SText "firstname;lastname;password|"
IBBS login script IBBS login script
Here is a script to log on to an IBBS system like Gene
Plantz's system in Chicago:
***************************************************************************
* I B B S . S C R --- Script for logging into IBBS BBS system *
PibTerm Script Language Reference Guide Page 74 PibTerm Script Language Reference Guide Page 74
***************************************************************************
* *
* Script: Ibbs.Scr *
* *
* Purpose: Connects to IBBS system. Designed for use as *
* attached script in dialing directory. *
* *
* Invocation: *
* *
* Execute "IBBS" *
* *
* Remarks: *
* *
* Change the values of "IDnnnn" and "password" to your own. *
* *
***************************************************************************
*
* Wait for name request
*
Waitstring "FIRST Name"
* Quit if not connected.
If ( NOT Connected ) Then
Exit
Endif
* Send ID number and password.
* Also request message reading from
* last previous message.
* PUT YOUR ID/PASSWORD HERE.
*
WaitQuiet 10
Stext "IDnnnn;password;m;r;*|"
*
CompuServe Login Script CompuServe Login Script
Here is a sample script to log on to CompuServe.
***************************************************************************
* C I S . S C R --- Script for connecting to CompuServe *
***************************************************************************
* *
* Script: Cis.Scr *
* *
* Purpose: Connects to CompuServe. *
* *
* Invocation: *
* *
* Execute "Cis" *
* *
* Remarks: *
* *
* Change the values of "user,id" and "password" to those of *
PibTerm Script Language Reference Guide Page 75 PibTerm Script Language Reference Guide Page 75
* your own CIS account. *
* *
***************************************************************************
*
* Wait a few seconds for network to activate
Suspend 300
* Wake up CompuServe
SText "^C"
* Wait for userid prompt
WaitString "User"
* Send userid -- PUT YOURS HERE
SText "user,id|"
* Wait for password prompt
WaitString "Password:"
* Send password -- PUT YOURS HERE
SText "password|"
* Wait for main prompt
WaitString " !"
* Turn on CompuServe B protocol
SetParam "BP" "1"
*
Using A Password File Using A Password File
PibTerm does not store the passwords for remote systems in
the dialing directory, for security purposes. However, you
may want to keep a file of passwords for remote systems
anyway, in order to better automate your scripts for those
systems. You can use the script facilities and text editor
in PibTerm to maintain a password file.
For example, if you regularly dial into a dozen different PC
Board systems, you could write separate very similar scripts
for each system with your unique ID and password.
Alternatively, you could write one general script and get
the password for a particular system from a password file.
Following is a script GETPASS.SCR which can be EXECUTEd by EXECUTE
another script to retrieve passwords from the password file.
The initial comments in this script detail how to create a
password file.
***************************************************************************
* G E T P A S S . S C R --- Get password for remote system *
***************************************************************************
*
* Dialing entry to get password for
Import DEntry Integer
* Name of dialed system to return to caller
Import SysName String
* Password to return to calling script
Import PassWord String
PibTerm Script Language Reference Guide Page 76 PibTerm Script Language Reference Guide Page 76
*
***************************************************************************
* *
* Script: GetPass.Scr *
* *
* Purpose: Returns entry in password file corresponding to *
* given dialing entry. *
* *
* Invocation: *
* *
* Execute 'GetPass' DialEnt SysName PassWord *
* *
* DialEnt --- Number of entry to get password for *
* SysName --- Name of System for entry 'DialEnt' *
* PassWord --- Password for entry 'DialEnt' *
* *
* Remarks: *
* *
* PibTerm does not store passwords for systems to be dialed in the *
* dialing directory. This is for security reasons. However, *
* you may find it convenient to maintain a file of passwords for *
* each system on your own. You can do this with the built-in *
* PibTerm editor, for example. *
* *
* This script provides a mechanism for accessing your password *
* file from another script invoked as the result of a PibTerm *
* request. Your dialing script just needs to invoke this script *
* as indicated above. *
* *
* Using a password file allows you to write one script which can *
* handle the signon sequence for a number of remote systems. For *
* example, you can write a generic routine to log into PC Board *
* systems. Then you can attach this generic script to the dialing *
* entries for all the PC Board systems you call. The major *
* difference will be the password, and using GETPASS.SCR allows you *
* to handle that difference rather easily. *
* *
* The password file is assumed to be called 'c:\pibterm\mypass.dat' *
* but you can change that to whatever name you like. The format *
* of the password file is simple: for each entry in the dialing *
* directory, place the system's name, followed by a colon (:), *
* followed by the system's password on the matching line *
* number in the password file. Hence, if your dialing directory *
* (PIBTERM.FON) has 25 entries, then your password file should also *
* have 25 lines. Each line has the name and password corresponding *
* to one dialing entry. For example, the 10th line in the password *
* file should have the name and password for the 10th entry in the *
* dialing directory *
* *
* A non-existent password is returned as a null string. *
* *
* While you won't stop a dedicated "hacker" from finding it, you *
* may want to assign a "hidden" file attribute to your password *
* file. The GetPass script will still be able to read it, but *
PibTerm Script Language Reference Guide Page 77 PibTerm Script Language Reference Guide Page 77
* casual "perusers" of your hard disk won't find it in a standard *
* DIR listing. *
* *
***************************************************************************
*
* Current entry in password file
Declare IEntry Integer
* Return null password in case of error
PassWord = ''
* Ditto for System Name
SysName = ''
* Make sure dialing # is reasonable
IF ( DEntry <= 0 ) THEN
EXIT
ENDIF
* Open password file.
* Change name to whatever you want.
*
Open 1 'c:\pibterm\MyPass.dat' 'Input'
*
* Check that open went OK -- if not,
* return to caller.
IF ( IOResult <> 0 ) THEN
EXIT
ENDIF
* Skip down to correct entry
*
FOR IEntry = 1 TO ( DEntry - 1 ) DO
Readln 1 SysName
IF ( IOResult <> 0 ) THEN
SysName = ''
CLOSE 1
EXIT
ENDIF
ENDFOR
* Read correct entry
Readln 1 SysName
*
IF ( IOResult <> 0 ) THEN
SysName = ''
CLOSE 1
EXIT
ENDIF
* Close password file
Close 1
* Parse out system name and password
* System Name begins line, then a colon (:),
* and then the password
Set IEntry = Index(':', SysName)
If ( IEntry = 0 ) then
SysName = ''
Exit
EndIf
Set Password = Trim( LTrim( SubStr(SysName, IEntry+1, Length(SysName)-IEntry)))
PibTerm Script Language Reference Guide Page 78 PibTerm Script Language Reference Guide Page 78
Set SysName = Trim( LTrim( SubStr(SysName, 1, IEntry-1)))
*
PC Board Login Script Using Password File PC Board Login Script Using Password File
As an example of how to use the GETPASS.SCR script, here is
a generalized PC Board login script written by Richard P.
Byrne:
*
Declare SysName String
Declare PassWord String
Declare DialEnt Integer
Declare StrIdx Integer
Declare TimeOut Integer 10
Declare LoopCount Integer 0
Declare CaptStatus String 'OFF'
*
******************************************************************************
* *
* Script: PCBOARD.SCR *
* *
* Purpose: Automated logon for PCBoard bulletin board systems. *
* *
* Invocation: This script is meant to be invoked from the dialing *
* directory. *
* *
* Remarks: Creates a file called PCB_NEWS.TXT that will contain the *
* first screenful of News displayed by the system (if any). *
* *
* This script calls the GETPASS script to return the name *
* of the system being accessed plus the password for that *
* system. *
* *
******************************************************************************
*
* Get entry number of system dialed
Set DialEnt = Dialed
* Wait for the "graphics" prompt
*
WaitString '=no?' TimeOut
If (WaitFound) then
* Use graphics for this call
SText 'Y Q|'
* Get name of system + password from Mypass.Dat file
*
Execute 'getpass' DialEnt SysName PassWord
*
* Format Password for use by combining
* with logon id (ie. first & last name)
*
PibTerm Script Language Reference Guide Page 79 PibTerm Script Language Reference Guide Page 79
Set PassWord = CONCAT('FirstName LastName ', PassWord)
Set PassWord = CONCAT( PassWord , '|' )
*
* Format System Name for log file entry
*
Set SysName = CONCAT('Captured News Items for ', SysName)
*
* Turn on capture in case there's news
*
Capture 'C:\pcbdir\PCB_News.Txt' 'E'
*
* Set capture file status flag to
* indicate an open log file
*
Set CaptStatus = 'ON'
*
* Write system name to log file
*
WriteLog '========================================================'
WriteLog SysName
WriteLog '========================================================'
* Send logon id and password
SText PassWord
* Set WaitTime to one second
WaitTime 1
* Loop until we get to main command prompt
Repeat
WaitList StrIdx 'continue?' '=no?' '(NS)?' '=yes?' 'Command?'
Set LoopCount = LoopCount + 1
DoCase StrIdx
Case 1
* Answer the "Press (Enter) to continue?"
* prompt
SText '|'
* And re-initialize our "dead-man"
* loop counter
*
Set LoopCount = 0
EndCase
Case 2
* Conference "auto-joined" ...
* Answer the "view others" prompt
SText '|'
* And re-initialize our "dead-man"
* loop counter
*
Set LoopCount = 0
EndCase
Case 3
* Answer the "More: (Y), (N), (NS)?"
* prompt
SText 'N|'
PibTerm Script Language Reference Guide Page 80 PibTerm Script Language Reference Guide Page 80
* And re-initialize our "dead-man"
* loop counter
*
Set LoopCount = 0
EndCase
Case 4
* Turn off capture and scan all
* message bases for mail
*
If ( CaptStatus = 'ON' ) Then
Capture
Set CaptStatus = 'OFF'
EndIf
SText 'A NS|'
Set LoopCount = 0
EndCase
EndDoCase
Until (StrIdx = 5) or (LoopCount = TimeOut)
EndIf
*
* If the capture file is still on (?),
* then turn it off
*
If ( CaptStatus = 'ON' ) Then
Capture
EndIf
* That's all folks!
Reading A New Configuration File Reading A New Configuration File
The PibTerm script language doesn't provide a direct means
of reading in a parameter configuration file like
PIBTERM.CNF. Reading in a new configuration file can be
very useful if you want to change a large number of
parameters at once. However, you can use the input/output
facilities of PibTerm to read a new configuration file.
Here is a script which can be EXECUTEd by another script, EXECUTE
and which will read and process a configuration file.
***************************************************************************
* R E A D C O N F . S C R --- Read configuration file *
***************************************************************************
*
* Name of configuration file to be read
Import ConfName String
*
***************************************************************************
* *
* Script: ReadConf.Scr *
* *
PibTerm Script Language Reference Guide Page 81 PibTerm Script Language Reference Guide Page 81
* Purpose: Reads a configuration file and resets PibTerm parameters. *
* *
* Invocation: *
* *
* Execute "ReadConf" ConfName *
* *
* ConfName --- Configuration file to read *
* *
* Example: Execute "ReadConf" "Bogusco.Cnf" *
* *
***************************************************************************
*
* Configuration line
Declare ConfLine String
* Configuration parameter name
Declare ConfName String
* Configuration parameter value
Declare ConfValue String
* Open configuration file.
*
Open 1 ConfName "Input"
*
* Check that open went OK -- if not,
* return to caller.
IF ( IOResult <> 0 ) THEN
EXIT
ENDIF
* Begin loop over configuration file.
REPEAT
* Read line from configuration file.
Readln 1 ConfLine
* Parse into parameter name and value.
*
ConfName = Substr( ConfLine, 1, 2 )
ConfValue = Substr( ConfLine, 4, 255 )
*
* Set parameter value.
SetParam ConfName ConfValue
*
UNTIL ( EOF( 1 ) )
* Close configuration file
Close 1
Defining Scripts For External Transfer Protocols Defining Scripts For External Transfer Protocols
As indicated in the "Guide to PibTerm", it is possible to
hook external file transfer protocols into PibTerm using
either batch files or scripts. The "Guide to PibTerm"
describes the procedure for using batch files. This section
discusses the use of scripts, which provides more
flexibility but requires considerably more programming
expertise.
PibTerm Script Language Reference Guide Page 82 PibTerm Script Language Reference Guide Page 82
This section presents scripts for use with MLINK.COM, the
module written by Paul Meiners that implements the MegaLink
protocol. The discussion on adding external file transfers
to PibTerm in the "Guide to PibTerm" also uses the
MLINK.COM program as an example, so you should have the
"Guide" handy for comparison.
Let's begin by recapitulating the parameters expected by the
external protocol module. In the case of MegaLink, the
MLINK.COM program takes argument of the form:
MLINK PORT n SPEED s RM download_directory
MLINK PORT n SPEED s SM
where 'n' is the communications port number, 's' is the baud
rate of the connection, RM indicates files are being
received, SM indicates files are being sent, and
'download_directory' is the name of the PibTerm download
directory.
For example, to receive files at 2400 baud over port 1, the
MLINK.COM invocation should be:
MLINK PORT 1 SPEED 2400 RM C:\DOWNLOAD
assuming that the PibTerm download directory is
'C:\DOWNLOAD', while to send files over port 2 at 1200 baud
the MLINK.COM invocation should be:
MLINK PORT 2 SPEED 1200 SM
In general, a script to receive a file or files contains
statements to do the following:
1. Save the current drive/directory using the new
GETDIR script command.
2. Move to the select download directory (parameter
DD= in terminal mode or HD= in host mode) using
the CHDIR script command, unless the external
protocol module has a way of specifying the
download directory name.
3. Pick up the file name to be transferred (parameter
FN=) using the GETPARAM script command.
4. Pick up any other information needed by the
external protocol handler, such as the port (PO=),
baud rate (BA=), etc., again using the GETPARAM
command.
5. Construct the DOS command to invoke the external
handler module, including the program name and all
of its parameters. This will involve a series of
PibTerm Script Language Reference Guide Page 83 PibTerm Script Language Reference Guide Page 83
SET statements to CONCAT the various parameters
together.
6. Execute the external handler using the DOS
command.
7. Return to the original drive/directory using the
CHDIR command.
A script to send files is similar. In terminal mode, you
don't need to specify a directory from which to send files.
In host mode, you should specify the host mode download
directory (HD=) and restrict files to be sent to that
subdirectory. The easiest way to do that is to simply
prepend the host mode directory to the file specification
provided by the user (from FN=). If a non-super-user
requests some other path, the script should strip it, or
just not allow the transfer.
When sending files, or receiving files with a non-batch
protocol, you need to know the file name(s) of the files to
be transferred. PibTerm will have already prompted for the
name. You gain access to the file specification provided
using the new FN= pseudo-parameter. FN= is a pseudo-
parameter because it isn't written to PIBTERM.CNF (and is
ignored if read from there), but it can be accessed using
the script command 'GetParam' just like a real parameter.
The value returned by FN is the file specification last
entered to PibTerm. You can look at SENDMLIN.SCR (appears
below) to see how to use FN=.
If you allow the protocol to execute in host mode, then you
also need to check within your script whether the protocol
has been invoked from host mode or from terminal mode. The
new pseudo-parameter HP= provides this information:
HP= -- in terminal mode (HP is a blank)
HP=N -- in host mode, user is a normal user
HP=S -- in host mode, user is a super-user
Like FN=, HP= is not written to PIBTERM.CNF and is ignored
if present in that file.
NOTE: For security reasons in host mode, when using
external protocols, make sure that the external
driver has either
(1) a mechanism for restricting the files
sent or received to the current directory, or
(2) a mechanism for specifying the
directories from which files are sent or into
which files are received.
PibTerm Script Language Reference Guide Page 84 PibTerm Script Language Reference Guide Page 84
Otherwise, non-super-users could use an external
protocol to transfer files you don't want
transferred, and which wouldn't be allowed by the
internal PibTerm transfer facilities because of
the XferList (PIBTERM.XFR) checking. No XferList PIBTERM.XFR
checking is available for external protocols.
Example: SENDMLIN.SCR for sending files with MegaLink Example: SENDMLIN.SCR for sending files with MegaLink
Here is the script SENDMLIN.SCR for interfacing MLINK.COM to
PibTerm for purposes of sending files to a remote system:
***************************************************************************
* S E N D M L I N . S C R --- Script interfacing MLINK to PibTerm *
***************************************************************************
* *
* Script: SendMLin.Scr *
* *
* Purpose: Interfaces external Megalink driver program MLINK.COM *
* to PibTerm for sending files. *
* *
* Invocation: *
* *
* Execute "SendMLin" *
* *
* Remarks: *
* *
* This script is designed to be automatically invoked by the *
* <ALT>S command when MegaLink has been defined as an external *
* protocol at <ALT>P, F)ile transfer, k) external file transfers. *
* *
***************************************************************************
* *
* File spec for files to transfer
Declare FileSpec String
* Baud rate for transfer
Declare BaudRate String
* Comm port number
Declare Port String
* Build MLink invocation line in this
Declare Mlink String
* Host mode flag
Declare HostMode String
* Upload directory
Declare UpDir String
*
**************************************************************************
* StripPath --- procedure to strip path from file name *
**************************************************************************
*
PROCEDURE StripPath
*
PibTerm Script Language Reference Guide Page 85 PibTerm Script Language Reference Guide Page 85
Declare I Integer
Declare L Integer
Declare Ch String
*
IF ( ( INDEX( '\' , FileSpec ) <> 0 ) OR ( INDEX( ':' , FileSpec ) <> 0 ) ) THEN
*
L = LENGTH( FileSpec )
I = L
*
REPEAT
I = I - 1
Ch = Substr( FileSpec, I, 1 )
UNTIL ( ( Ch = '\' ) OR ( Ch = ':' ) )
*
FileSpec = SUBSTR( FileSpec, I + 1 , L - I )
*
ENDIF
*
ENDPROC StripPath
*
**************************************************************************
* SendMLin -- Main Routine *
**************************************************************************
*
* Find out if we're in host mode
*
GetParam 'HP' HostMode
* Get port number
GetParam 'PO' Port
* Get baud rate
GetParam 'BA' BaudRate
* Get file spec
GetParam 'FN' FileSpec
* Get host mode directory, and
* prepend to file spec, after
* stripping any other directory spec.
IF ( HostMode = 'N' ) THEN
GetParam 'HD' UpDir
Call StripPath
Set FileSpec = CONCAT( UpDir , FileSpec )
ENDIF
* Build MLink invocation line
*
Set Mlink = CONCAT( 'MLink port ' , Port )
Set Mlink = CONCAT( CONCAT( Mlink , ' speed ' ), BaudRate )
Set Mlink = CONCAT( CONCAT( Mlink , ' SM ' ), FileSpec )
*
* Echo built line to screen
Writeln " "
Writeln "Invoking MLink as follows:"
Writeln Mlink
Writeln " "
* Echo Mlink line to capture file
*
PibTerm Script Language Reference Guide Page 86 PibTerm Script Language Reference Guide Page 86
Writelog "Invoking MLink as follows:"
Writelog Mlink
* Call MLink
Dos Mlink
*
Example: RECLINK.SCR for receiving files with MegaLink Example: RECLINK.SCR for receiving files with MegaLink
Here is the script RECMLINK.SCR for interfacing MLINK.COM to
PibTerm for purposes of receiving files from a remote
system:
***************************************************************************
* R E C M L I N K . S C R --- Script interfacing MLINK to PibTerm *
***************************************************************************
* *
* Script: RecMLink.Scr *
* *
* Purpose: Interfaces external Megalink driver program MLINK.COM *
* to PibTerm for receiving files. *
* *
* Invocation: *
* *
* Execute "RecMLink" *
* *
* Remarks: *
* *
* This script is designed to be automatically invoked by the *
* <ALT>R command when MegaLink has been defined as an external *
* protocol at <ALT>P, F)ile transfer, k) external file transfers. *
* *
***************************************************************************
* *
* Baud rate for transfer
Declare BaudRate String
* Comm port number
Declare Port String
* Build Mlink invocation line in this
Declare MLink String
* Download directory
Declare DownDir String
* Length of download directory
Declare L Integer
* Host mode flag
Declare HostMode String
* Find out if we're in host mode
*
GetParam 'HP' HostMode
* Get download directory.
* If in host mode, use host mode upload
* directory.
*
PibTerm Script Language Reference Guide Page 87 PibTerm Script Language Reference Guide Page 87
IF ( HostMode = ' ' ) THEN
GetParam 'DD' DownDir
ELSE
GetParam 'HU' DownDir
ENDIF
* Get port number
GetParam 'PO' Port
* Get baud rate
GetParam 'BA' BaudRate
* Strip final '\' if any from download dir
Set L = LENGTH( DownDir )
*
IF ( Substr( DownDir, L, 1 ) = '\' ) THEN
Set DownDir = Substr( DownDir, 1, L - 1 )
ENDIF
* Build Mlink invocation line
*
Set MLink = CONCAT( 'Mlink port ' , Port )
Set MLink = CONCAT( CONCAT( MLink , ' speed ' ), BaudRate )
Set MLink = CONCAT( CONCAT( MLink , ' rm ') , DownDir )
*
* Echo MLink line to screen
Writeln " "
Writeln "Invoking MLink as follows:"
Writeln MLink
Writeln " "
* Echo MLink line to capture file
*
Writelog "Invoking MLink as follows:"
Writelog MLink
* Call MLink
Dos MLink
*
Example: SENDZMOD.SCR for sending files with Zmodem Example: SENDZMOD.SCR for sending files with Zmodem
The PibTerm release materials already include a definition
of Zmodem as an external file transfer protocol using the
batch files RECZMOD.BAT and SENDZMOD.BAT to invoke DSZ.COM. RECZMOD.BAT SENDZMOD.BAT
As an alternative, the following presents send and receive
scripts for use with DSZ.COM.
Here the script SENDZMOD.SCR for interfacing DSZ.COM to
PibTerm for purposes of sending files to a remote system:
***************************************************************************
* S E N D Z M O D . S C R --- Script interfacing DSZ to PibTerm *
***************************************************************************
* *
* Script: SendZMod.Scr *
* *
PibTerm Script Language Reference Guide Page 88 PibTerm Script Language Reference Guide Page 88
* Purpose: Interfaces external Zmodem driver program DSZ.COM *
* to PibTerm for sending files. *
* *
* Invocation: *
* *
* Execute "SendZmod" *
* *
* Remarks: *
* *
* This script is designed to be automatically invoked by the *
* <ALT>R command when Zmodem has been defined as an external *
* protocol at <ALT>P, F)ile transfer, k) external file transfers. *
* *
***************************************************************************
* *
* File spec for files to transfer
Declare FileSpec String
* Baud rate for transfer
Declare BaudRate String
* Comm port number
Declare Port String
* Zmodem block size
Declare Block String
* Build DSZ invocation line in this
Declare Zmodem String
* 'restrict ' for host mode, else null
Declare Restrict String
* Host mode flag
Declare HostMode String
* Saves drive/directory we're in now
Declare CurDrive String
Declare CurDir String
* Host mode download directory =
* directory remote callers can download from.
Declare UpDir String
* Length of directory name
Declare L Integer
* Get port number
GetParam 'PO' Port
* Get baud rate
GetParam 'BA' BaudRate
* Get Zmodem block size
GetParam 'ZB' Block
Set Block = '50'
* Get file spec
GetParam 'FN' FileSpec
* Get host mode flag
GetParam 'HP' HostMode
* Get directory we're in now
GetDir CurDrive CurDir
* If host mode, move to host mode
* download directory and set restrict.
Set Restrict = ''
*
PibTerm Script Language Reference Guide Page 89 PibTerm Script Language Reference Guide Page 89
IF ( HostMode <> ' ' ) THEN
*
GetParam 'HD' UpDir
* Strip final '\' if any from download dir
Set L = LENGTH( UpDir )
*
IF ( Substr( UpDir, L, 1 ) = '\' ) THEN
Set UpDir = Substr( UpDir, 1, L - 1 )
ENDIF
* Move to download dir
ChDir UpDir
* Set restrict if not super-user
IF ( HostMode <> 'S' ) THEN
Set Restrict = 'restrict '
ENDIF
*
ENDIF
* Build DSZ invocation line
*
Set Zmodem = CONCAT( 'DSZ port ' , Port )
Set Zmodem = CONCAT( CONCAT( Zmodem , ' speed ' ), BaudRate )
Set Zmodem = CONCAT( CONCAT( Zmodem , ' d z pL' ), Block )
Set Zmodem = CONCAT( CONCAT( CONCAT( Zmodem , Restrict ), ' sz ' ), FileSpec )
*
* Echo built line to screen
Writeln " "
Writeln "Invoking DSZ as follows:"
Writeln Zmodem
Writeln " "
* Echo Zmodem line to capture file
*
Writelog "Invoking DSZ as follows:"
Writelog Zmodem
* Call DSZ
Dos Zmodem
* Return to original directory if host mode
IF ( HostMode <> ' ' ) THEN
Set CurDir = CONCAT( CONCAT( CurDrive , ':\' ), CurDir )
Chdir CurDir
ENDIF
Example: RECZMOD.SCR for receiving files with Zmodem Example: RECZMOD.SCR for receiving files with Zmodem
Here is the script RECZMOD.SCR for interfacing DSZ.COM to
PibTerm for purposes of sending files to a remote system:
***************************************************************************
* R E C Z M O D . S C R --- Script interfacing DSZ to PibTerm *
***************************************************************************
* *
* Script: RecZMod.Scr *
* *
PibTerm Script Language Reference Guide Page 90 PibTerm Script Language Reference Guide Page 90
* Purpose: Interfaces external Zmodem driver program DSZ.COM *
* to PibTerm for receiving files. *
* *
* Invocation: *
* *
* Execute "RecZmod" *
* *
* Remarks: *
* *
* This script is designed to be automatically invoked by the *
* <ALT>R command when Zmodem has been defined as an external *
* protocol at <ALT>P, F)ile transfer, k) external file transfers. *
* *
***************************************************************************
* *
* Baud rate for transfer
Declare BaudRate String
* Comm port number
Declare Port String
* Build DSZ invocation line in this
Declare Zmodem String
* Saves drive/directory we're in now
Declare CurDrive String
Declare CurDir String
* Download directory
Declare DownDir String
* Length of download directory
Declare L Integer
* Host mode flag
Declare HostMode String
* "Restrict" for host mode, else null
Declare Restrict String
* Get directory we're in now
GetDir CurDrive CurDir
* Get port number
GetParam 'PO' Port
* Get baud rate
GetParam 'BA' BaudRate
* Find out if we're in host mode
*
GetParam 'HP' HostMode
* Get download directory.
* If in host mode, use host mode upload
* directory.
*
Set Restrict = ''
*
IF ( HostMode = ' ' ) THEN
GetParam 'DD' DownDir
ELSE
GetParam 'HU' DownDir
IF ( HostMode = 'N' ) THEN
Set Restrict = 'restrict '
ENDIF
PibTerm Script Language Reference Guide Page 91 PibTerm Script Language Reference Guide Page 91
ENDIF
* Strip final '\' if any from download dir
Set L = LENGTH( DownDir )
*
IF ( Substr( DownDir, L, 1 ) = '\' ) THEN
Set DownDir = Substr( DownDir, 1, L - 1 )
ENDIF
* Move to download directory
Chdir DownDir
* Build DSZ invocation line
*
Set Zmodem = CONCAT( 'DSZ port ' , Port )
Set Zmodem = CONCAT( CONCAT( Zmodem , ' speed ' ), BaudRate )
Set Zmodem = CONCAT( CONCAT( CONCAT( Zmodem , ' d ' ), Restrict ), 'rz -y')
*
* Echo Zmodem line to screen
Writeln " "
Writeln "Invoking DSZ as follows:"
Writeln Zmodem
Writeln " "
* Echo Zmodem line to capture file
Writelog "Invoking DSZ as follows:"
Writelog Zmodem
* Call DSZ
Dos Zmodem
* Return to original directory
*
Set CurDir = CONCAT( CONCAT( CurDrive , ':\' ), CurDir )
*
Chdir CurDir