home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 3 Comm
/
03-Comm.zip
/
script.doc
< prev
next >
Wrap
Text File
|
1994-11-29
|
28KB
|
938 lines
INTRODUCTION
------------
Connect Scripting is the name that CompuServe has given to the scripting
language found in its various proprietary software programs, including
the CompuServe Information Manager. Connect Scripting is, and does,
just what the name implies. It is a scripting language designed to
allow CIM to navigate through alternate networks to access the
CompuServe host computers.
REASON
------
There are numerous networks that CIM needs to support so that CompuServe
members, both domestic and international, can have access to the
CompuServe Information Service. Some examples of these networks would be
Tymnet, SprintNet, DataPac (Canada), Datex-P (Germany), FALNet
(Australia), Fenics (Japan), and, of course, the CompuServe Network.
Each network has it's own sequence of commands to route your call through
to CompuServe.
In the past, these procedures were programmed into the Information
Manager, which meant that anytime a network changed it's logon procedure,
or a new network was added that allowed access to CompuServe, a new
version of the Information Manager had to be created. Also, what about
those members who use modem pools or local area networks that required
certain access commands just to get an outside line so that they, in
turn, could call a local access number? Connect scripting was implemented
to allow such accesses and to make updating to available networks easier.
USAGE
-----
Those who have had experience with programming languages will
find it easy to learn the connect script language for CIM. For
those members it is a matter of being familiar with the semantics and
syntax and reviewing some examples. Both are provided with
this document.
Others will need to little bit more help. Since it is impossible to teach
programming techniques with a few short paragraphs of explanations, there
is a better way for those who need that extra help. It would be better to
take a script that already exists and simply modify it to match your
situation. All of the scripts that are included basically follow the
same pattern: dial the number, access the network, send the correct
responses to the expected prompts, and then give control over to CIM once
you reach CompuServe. There is no need to "reinvent the wheel". Take a
script that already exist and alter it. There are examples included to
help.
EXAMPLES
--------
When the new script is created, it needs to be included in the list with
the other scripts. To do this you will need to alter a portion of the
CONNECT.SCR script. Looking at the example below, there are three places
where alterations are necessary for you script to be included.
Let's say we created a script for the "MakeBelieve" network. After
creating the script for the MakeBelieve Network we would name the script
file "MAKEBE.SCR" and put it in the CCL folder for the Macintosh version
of CIM or in the same directory where the CIM.EXE file is located for the
DOS version. The script needs to be included in the list that is in the
beginning of the CONNECT.SCR. You will find the MakeBelieve script
entered as #9 on the list. We had to move the scripts that follow it on
the list down one line and renumbers them so that the scripts will show
up alphabetized in the Network popup menu in the session settings:
!---------------------------------------------------------------------!
!
!
! Copyright (c) 1991
! by CompuServe Incorporated, Columbus, Ohio
!
! The information in this software is subject to change without
! notice and should not be construed as a commitment by CompuServe.
!
! Connect Script:
!
! Handles CompuServe and Direct.
!---------------------------------------------------------------------!
!+N
CompuServe = 1; ! "CompuServe"
Telenet = 2; ! "Telenet"
Tymnet = 3; ! "Tymnet"
DataPac = 4; ! "DataPac"
CSC_Europe = 5; ! "CSC Europe"
CSC = 6; ! "CSC"
ConnNet = 7; ! "ConnNet"
LATA = 8; ! "LATA"
MakeBelieve = 9; ! "MakeBelieve"
Telepac = 10; ! "Telepac"
Then there needs to be an entry in the CONNECT.SCR file like this: (the
new entry is the last line of the following example)
UsingModem = %TRUE;
if %Network = CompuServe goto Connect_CIS;
if %Network = Telenet goto Connect_Telenet;
if %Network = Tymnet goto Connect_Tymnet;
if %Network = DataPac goto Connect_DataPac;
if %Network = CSC_Europe goto Connect_CSC_Europe;
if %Network = CSC goto Connect_CSC;
if %Network = MakeBelieve goto Connect_MakeBelieve; (this is the new line)
Then, you will need to put a label later in the file so that when you use
the MakeBelieve network the script will be able to find
it. The label will look like this:
!--------------------------!
! Connect to MakeBelieve !
!--------------------------!
Connect_MakeBelieve:
(This is the label for the new script)
call %Dir & "makebe.scr" () : Result;
(This will cause the script to execute)
goto Handle_Network_Return;
(This is a standard call for all scripts )
Again, you will want to take a look at the scripts that are included as
examples and use those entries as a guide.
CONNECT SCRIPT DOCUMENTATION
Semantic Information:
ASSIGNMENT: Used to assign a value to a variable or a global symbol.
The identifier on the left hand side automatically takes on the
type of the expression on the right hand side.
identifier = expression;
Example:
CompuServe = 1; ! "CompuServe"
CALL STATEMENT: Allows a call to an external script file. The
expression in the call statement must be a string expression that
specifies the name of the script file to be called. Also, note
that the case is irrelevant concerning the expression (script
name).
call expression [arguments [return_value]] ;
Example:
call %Dir & "first.scr" () : Result;
Arguments and return values are optional. Arguments are
referenced as Arg1, Arg2, Arg3, etc. within the called script.
Example:
call %Dir & "phone.scr" (dial) : Result;
("(dial)" is Arg1 for "phone.scr")
On return from the call, the return value identifier (if one
exists) is assigned the exit value from the called script.
Example:
("Result" is the return value identifier in the
above example)
If the called script is not successfully interpreted, both the
called script and the calling script fail.
COMMENTS: Comments begin with the symbol '!' and extend to the end of
the line.
Example:
CompuServe = 1; ! "CompuServe"
CONTROL CHARACTERS: Within a string, a control character is specified
by prefixing a character with the '^' (caret) symbol. For
example, doing a send of the string "^M" will cause a carriage
return to be sent.
Example:
carriage_return = "^M";
DEFINE: Used to define global symbols.
Example:
define %CR = "^M";
EXPRESSIONS:
Logical operators: and, or, not
Relational operators: < , <= , = , <> , > , >=
String catenation: &
Arithmetic operators: +, -, *, /
Empty_statement: ;
Valid expressions: expr1 or expr2
expr2 and expr3
not expr3
expr4 <= expr4
expr5 & expr6
- expr6 + expr7
expr7 * expr8
(( expr8 - expr9 ) > expr10 )
EXIT STATEMENT: Terminates the script and causes a value to be passed
back to the application or thecalling script (as the return
value). The exit expression value must be a non-negative integer
and is often a global symbol that was defined by the application.
exit expression ;
Example:
exit %Success;
GOSUB STATEMENT: The identifier in the gosub statement must be a
label. The address of the statement following the gosub is saved
and control is transferred to the label specified. A return
statement will return control to the saved address.
gosub identifier ;
Example:
gosub Hangup_Connect;
GOTO STATEMENT: The identifier in the goto statement must be a label.
Control is transferred to the label specified.
goto identifier ;
Example:
if Result = %Cancel goto Cancel_Connect;
IDENTIFIERS: Identifiers are labels, variables, and global symbols.
Labels and variables must begin with a letter and global
symbols must begin with a percent sign (%). Identifiers may
contain letters, digits, and underscores. The maximum length of
an identifier is 31 characters.
IF STATEMENT: The if expression must be either an integer expression
or a logical expression. If the value of the expression is
non-zero (true) then the associated goto is executed.
if expression goto identifier ;
Example:
if Result = %Cancel goto Cancel_Connect
IFNDEF STATEMENT: Used to conditionally assign a value to a global
symbol. The assignment takes place only if the symbol is not
currently defined.
ifndef global_symbol = expression ;
INIT STATEMENT: Initializes the port. The init expressions must be
integers (they represent port and baud rate).
init expression , expression ;
Example:
init %Port, %BaudRate;
After this statement is executed, the global symbol %_init
contains the value returned.
LABELS: Labels are non-executable statements that allows flow control
of the script and is used in conjunction with the goto and gosub
statements. Labels end with a colon (:).
Example:
Do_CIS_Script:
ON-CANCEL STATEMENT: Used to define a cancel label. This is the
default transfer label on cancel during a wait statement. (Note:
Do not depend on the stack state after this statement. It is a
Goto and does not respect returns, be careful of stack overflow!)
on cancel goto identifier ;
Example:
on cancel goto Cancel_Connect;
RESET STATEMENT: Resets the port.
reset;
RETURN STATEMENT: Returns control to the address that was saved when
the associated gosub was called.
return;
SEND STATEMENT: The send expression may be integer or string.
Integer expressions are converted to character strings before
being sent.
send expression ;
Example:
send %CR;
SEND-ESCI STATEMENT: Sends the expression as an ESC I response, along
with its 'checksum' as computed per CompuServe specifications.
sendi expression ;
SEND-MODEM STATEMENT: Interprets modem commands within the string as
the string is sent (~ = pause, # = break, \ = break in WinCIM
only). To send a break character to your modem, use a
caret (^) before the # symbol.
sendm expression ;
Example:
sendm "^#";
SHOW STATEMENT: The show expression may be integer or string. Integer
expressions are converted to character strings before being shown
in the dialog.
show "text_string" ; (can also be a variable)
Example:
show "Connect cancelled"; -or- show %FailureMsg;
VARIABLES: There is no need to declare variables (local) before using
them in an assigment statement. The type (either integer or
string) of a variable depends on the type of whatever expression
is assigned into it. The type of a variable will change
dynamically if a different type of expression is later assigned
into it. Since a variable does NOT have a default value OR type,
any variables that appear on the right hand side of an assignment
must be initialized before being used. This is VERY important!
LOCAL:
The scope of a variable is local to the current script file. If a
secondary script is called, it cannot access the value of a
variable from the primary script. Reusing a variable name in the
secondary script will cause a new (uninitialized) local copy of
that variable to be created. On return to the primary script,
the original variable (containing the same value that it
contained prior to the call) is again accessible
GLOBAL SYMBOLS:
Global symbols are similar to variables except for their scope.
They can be initialized prior to the execution of a script and
they maintain values across multiple script files. They provide
a mechanism for setting up initial values and for passing
information between script files. Also, global symbols must
begin with a percent sign (%) and are defined by using the define
command.
Example:
define %CR = "^M";
WAIT STATEMENT: Tries to match incoming characters against the
specified strings. If there is a match the associated goto is
executed. The wait statement expression is an integer expression
that represents tenths of a second (e.g., 50 = 5 seconds). The
wait statement continues trying to do a match for the length of
time specified.
wait wait_item goto identifier
The else part of the wait statement is used to handle a cancel
(on-cancel). If the user cancels before there is a match or a
timeout then the goto associated with the else will be executed.
If the wait statement does not have an else part then control
transfers to the default cancel label specified in the most
recently executed "on cancel" statement. If no cancel label is
specified then control transfers to the statement following the
wait.
until expression else goto identifier ;
Example:
wait
"UIC:" goto Send_ETX,
"Host Name:" goto Send_Host_Name,
"User ID:" goto Send_ID,
"Password:" goto Send_Password
until 80;
If no match strings are specified, incoming characters and
user attempts to cancel are ignored. A wait statement with
no match strings is in effect an unconditional pause for
the length of time specified.
Note that wait statements provide the only places during
script execution where user cancels will be processed.
Sample scripts:
!---------------------------------------------------------------------!
! !
! Copyright (c) 1991 !
! by CompuServe Incorporated, Columbus, Ohio !
! !
! The information in this software is subject to change without !
! notice and should not be construed as a commitment by CompuServe. !
! !
! Connect Script: !
! !
! Handles CompuServe and Direct. !
!---------------------------------------------------------------------!
!+N
CompuServe = 1; ! "CompuServe"
Telenet = 2; ! "Telenet"
Tymnet = 3; ! "Tymnet"
DataPac = 4; ! "DataPac"
CSC_Europe = 5; ! "CSC Europe"
CSC = 6; ! "CSC"
ConnNet = 7; ! "ConnNet"
LATA = 8; ! "LATA"
Telepac = 9; ! "Telepac"
Istel = 10; ! "Istel"
Datex_P = 11; ! "Datex-P"
Dialplus = 12; ! "Dialplus"
NIF = 13; ! "NIF"
CompuPass = 14; ! "CompuPass"
FALNET = 15; ! "FALNET"
Direct = 16; ! "Direct"
!-N
define %CR = "^M";
define %FALSE = 0;
define %TRUE = 1;
dial = 0;
hangup = 1;
!------------------------!
! Main Program !
!------------------------!
init %Port, %BaudRate;
if %_init goto Continue_Connect;
define %FailureMsg = "Could not initialize port";
goto Connect_Fatal;
Continue_Connect:
UsingModem = %FALSE;
call %Dir & "first.scr" () : Result;
if Result = %Cancel goto Cancel_Connect;
if Result = %Failure goto Connect_Failure;
if Result = %Fatal goto Connect_Fatal;
on cancel goto Cancel_Connect;
DirectConnect = (%Network = Direct);
if DirectConnect goto Connect_CIS;
call %Dir & "phone.scr" (dial) : Result;
if Result = %Cancel goto Cancel_Connect;
if Result = %Failure goto Connect_Failure;
if Result = %Fatal goto Connect_Fatal;
UsingModem = %TRUE;
if %Network = CompuServe goto Connect_CIS;
if %Network = Telenet goto Connect_Telenet;
if %Network = Tymnet goto Connect_Tymnet;
if %Network = DataPac goto Connect_DataPac;
if %Network = CSC_Europe goto Connect_CSC_Europe;
if %Network = CSC goto Connect_CSC;
if %Network = ConnNet goto Connect_ConnNet;
if %Network = LATA goto Connect_LATA;
if %Network = Telepac goto Connect_Telepac;
if %Network = Istel goto Connect_Istel;
if %Network = Datex_P goto Connect_Datex_P;
if %Network = Dialplus goto Connect_Dialplus;
if %Network = NIF goto Connect_NIF;
if %Network = CompuPass goto Connect_CompuPass;
if %Network = FALNET goto Connect_FALNET;
define %FailureMsg = "Network not supported";
goto Connect_Fatal;
!----------------------!
! Connect to Telenet !
!----------------------!
Connect_Telenet:
call %Dir & "telenet.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to Tymnet !
!----------------------!
Connect_Tymnet:
call %Dir & "tymnet.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to DataPac !
!----------------------!
Connect_DataPac:
call %Dir & "datapac.scr" () : Result;
goto Handle_Network_Return;
!-------------------------!
! Connect to CSC Europe !
!-------------------------!
Connect_CSC_Europe:
call %Dir & "csc.scr" (%TRUE) : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to CSC !
!----------------------!
Connect_CSC:
call %Dir & "csc.scr" (%FALSE) : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to ConnNet !
!----------------------!
Connect_ConnNet:
call %Dir & "connnet.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to LATA !
!----------------------!
Connect_LATA:
call %Dir & "lata.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to Telepac !
!----------------------!
Connect_Telepac:
call %Dir & "telepac.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to Istel !
!----------------------!
Connect_Istel:
call %Dir & "istel.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to Datex-P !
!----------------------!
Connect_Datex_P:
call %Dir & "datex.scr" () : Result;
goto Handle_Network_Return;
!----------------------!
! Connect to Dialplus !
!----------------------!
Connect_Dialplus:
call %Dir & "dialplus.scr" () : Result;
goto Handle_Network_Return;
!------------------!
! Connect to NIF !
!------------------!
Connect_NIF:
call %Dir & "fenics.scr" (%TRUE) : Result;
goto Handle_Network_Return;
!------------------------!
! Connect to CompuPass !
!------------------------!
Connect_CompuPass:
call %Dir & "fenics.scr" (%FALSE) : Result;
goto Handle_Network_Return;
!------------------------!
! Connect to CompuPass !
!------------------------!
Connect_FALNET:
call %Dir & "falnet.scr" (%FALSE) : Result;
goto Handle_Network_Return;
!-------------------------!
! Handle Network Return !
!-------------------------!
Handle_Network_Return:
if Result = %Success goto Do_CIS_Script;
if Result = %Cancel goto Cancel_Connect;
if Result = %Fatal goto Connect_Fatal;
goto Connect_Failure;
!-------------------!
! Connect to CIS !
!-------------------!
Connect_CIS:
send %CR;
Do_CIS_Script:
call %Dir & "cserve.scr" (DirectConnect) : Result;
if Result = %Failure goto Connect_Failure;
if Result = %Cancel goto Cancel_Connect;
if Result = %Fatal goto Connect_Fatal;
exit %Success;
Connect_Failure:
gosub Hangup_Connect;
reset;
exit %Failure;
Connect_Fatal:
gosub Hangup_Connect;
reset;
exit %Fatal;
Hangup_Connect:
if not UsingModem goto Hangup_Done;
call %Dir & "phone.scr" (hangup);
Hangup_Done:
return;
Cancel_Connect:
show "Connect cancelled";
reset;
exit %Cancel;
!---------------------------------------------------------------------!
! !
! Copyright (c) 1991 !
! by CompuServe Incorporated, Columbus, Ohio !
! !
! The information in this software is subject to change without !
! notice and should not be construed as a commitment by CompuServe. !
! !
! CSERVE Script: !
! Connect to CIS. !
! First argument is %TRUE if direct connect and %FALSE otherwise !
! Success: returns %Success !
! Failure: saves error msg in %FailureMsg and returns %Failure !
! or %Fatal (depending on severity). !
!---------------------------------------------------------------------!
DirectConnect = Arg1;
show "Connecting to CompuServe Network";
Tries = 7;
on cancel goto Return_Cancel;
FirstTry = %TRUE;
FailStr = "";
ETX = "^C";
CompuServeHost = "CPS^M";
Start_Connect:
if Tries = 0 goto CIS_Failure;
Tries = Tries - 1;
Connect_Wait:
wait
"UIC:" goto Send_ETX,
"Host Name:" goto Send_Host_Name,
"User ID:" goto Send_ID,
"Password:" goto Send_Password
until 80;
if not DirectConnect goto Send_CR;
sendm "###";
Send_CR:
send %CR;
goto Start_Connect;
Send_ETX:
send ETX;
goto Connect_Wait;
Send_Host_Name:
send CompuServeHost;
goto Connect_Wait;
Send_ID:
show "Logging onto CompuServe";
send %UserID & %LogonParams & "/INT\" & %Password & %CR;
goto Logon_Wait;
Send_Password:
send %Password;
Logon_Wait:
wait
"CompuServe" goto Return_Success,
"^F" goto Return_Success,
"? LOG" goto Process_Log_Msg,
"??LOG" goto Process_Log_Msg,
" NTW" goto Logon_Failure,
"^[" goto Send_Response
until 200;
goto CIS_Failure;
Process_Log_Msg:
wait
"INE" goto Bad_ID,
"ISX" goto Bad_ID_Syntax,
"SIL" goto System_Unavailable,
"SIU" goto System_Unavailable,
"SNA" goto System_Unavailable,
"STU" goto System_Unavailable
until 50;
goto Try_Again;
Bad_ID:
FailStr = "Incorrect user ID or password";
goto Try_Again;
Bad_ID_Syntax:
FailStr = "Incorrect user ID syntax";
goto Try_Again;
System_Unavailable:
define %FailureMsg = "The system is unavailable, try again later";
exit %Fatal;
Try_Again:
if not FirstTry goto CIS_Fatal;
send ETX;
FirstTry = %FALSE;
wait
"User ID" goto Send_ID
until 140;
goto CIS_Fatal;
Logon_Failure:
define %FailureMsg = "Remote is busy or unavailable";
exit %Fatal;
Send_Response:
sendi %ESCIResponse;
exit %Success;
CIS_Failure:
if FailStr <> "" goto Return_Fail_Msg;
define %FailureMsg = "Unable to connect to CompuServe host";
exit %Failure;
CIS_Fatal:
if FailStr <> "" goto Return_Fatal_Msg;
define %FailureMsg = "Unable to connect to CompuServe host";
exit %Fatal;
Return_Fail_Msg:
define %FailureMsg = FailStr;
exit %Failure;
Return_Fatal_Msg:
define %FailureMsg = FailStr;
exit %Fatal;
Return_Success:
exit %Success;
Return_Cancel:
exit %Cancel;
Global variables:
[{] %Cancel -The user has cancelled the current operation
-alternate(secondary connection) will not be attempted.
%ESCIResponse - the response to an ESC-I sequence that was
received during connection.
[{] %Failure - A failure has occured - alternate can be
attempted.
[{] %Fatal - A fatal error has occured - alternate will not be
attempted.
[{] %Success - connection was successful.
%_init - contains the success flag returned after the
completion of the INIT call.
[{]The above indicated globals are return values . One of
these globals must be returned to indicate the success or
failure of the called script.
The following globals are set to the information that has been entered in
the Session Settings:
%UserID - set to the User ID.
%Password - set to the password.
%Phone - set to the phone number in the primary connect
section.
%NetWork - set to the network indicated in the primary
connect section.
%BaudRate - set to the baud rate as indicated in the
Primary Connection section.
%Retry - set to the number entered in the Retries field of
the primary connect section.
%DialType - set to the dial type. (1=Tone, 2=Pulse,
3=Manual)
%Port - set to the current commport. (For the Macintosh
version: 1=Modem port, 2=Printer port)
%Dir - set to the pathname for the Data Files Directory
(DOS). This is not used for the Macintosh version.
The following globals are set to the information that has been entered in
the Modem Control Strings (under Session Settings):
%mdm_Init - set to the contents of the Initialize: field.
%mdm_Prefix - set to the contents of the Prefix: field.
[{] %mdm_Reset - set to the contents of the Reset: field.
[{] %mdm_Tone_Dial - set to the contents of the Dial Tone:
field.
[{] %mdm_Pulse_Dial - set to the contents of the Dial Pulse:
field.
[{] %mdm_Hangup - set to the contents of the Hang Up: field.
%mdm_Suffix - set to the contents of the Suffix: field.
%mdm_EscapeCode - set to the contents of the Escape:
field.
%mdm_Success - set to the contents of the Connect: field.
%mdm_Ack - set to the contents of the Acknowledge: field.
%mdm_Speaker - set to the state of the Speaker Off
selection (speaker is on by default).
%LogonParams - set to the entries found in the Logon
Params field in the Modem section.
%mdm_ECOn - set to the contents of the Error Correction
field.
%mdm_DCOn - set to the contents of the Data Compression
field.
%X121Address - set to the X121 call address if using
Eicon X.25 software.
[{] The above globals will automatically have the %mdm_Prefix as
a prefix and %mdm_Suffix as a suffix.