20.  Startup

The CFS Startup mechanism offers the user the possibility of executing a sequence of commands automatically after starting the program. The commands or selection records to be processed will be read from a SAM file (Startup file). Commands that could be executed from a Startup file include user-specific program modes. The syntax used in Startup files has been fully described in the last chapter, "Procedure Language".

Startup File Hierarchy

1) After being called, CFS will first look for a file with the link name of CFSCMD or CFSCMD1. If the user has assigned a file with this link name, then it will be used as the Startup file.

A file assigned with the CFSCMD link name may only be processed in dialog mode. A file with the link name CFSCMD1 may additionally be used when calling CFS from procedures, or in Enter mode (SETSW ON=1). Exception: SETSW ON=11.

2) If no TFT entry with the link name CFSCMD exists, then the Job name of the LOGON command (/.name LOGON ...) will be tried together with the prefix 'CFS.STARTUP'. If a file named CFS.STARTUP.name exists under that same userid exists, then it wll be used as the Startup file.

If no CFS.STARTUP.name file exists under the users own userid, then CFS will look for a central file with this name in the userid under which CFS is stored (normally $CFS, or $TSOS).

3) If none of the above files exist, CFS will look for a file called CFS.STARTUP.STD under the users own userid.

If the file CFS.STARTUP.STD does not exist under the users own userid, then CFS will make a final attempt to locate a central file with this name in the userid under which CFS is located (normally $CFS, or $TSOS).

The Startup file is a CFS procedure which will be executed automatically when CFS is started. For the procedure-specific language elements that are applicable to Startup files, see Chapter 19 "Procedure Language".

Note:

If a Startup file conforming to one of the above naming conventions exists, but the user does not want it used as a Startup file for the current CFS run, then a /FILE *DUMMY,LINK=CFSCMD command should be issued before loading CFS.

Example of a Startup File:

*002 FILE=NO
/TCHNG OFLOW=NO
*PROMPT &VAR,'Should Connection 1 be opened to userid..... ? (Y/N)'
*IF &VAR = 'N' SKIP .OC2
1/LOGON userid1,acct,&(PASSW)
^
.OC2
*PROMPT &VAR,'Should Connection 2 be opened to application UTM1 ? (Y/N)'
*IF &VAR = 'N' SKIP .NO-UTM
2UTM1,CFSTERM1
KDCSIGN .......
^
.NO-UTM
*WRITE 'Loading the P keys '
PL module
*WRITE 'Loading CFS Command Memory'
* Load CFS Command Memory (Remark)
*&SUFFIX = &LOGNAM
*IF &SUFFIX = '' &SUFFIX = &ACCT
LM CFS.MEM.&SUFFIX
* Define Standard User Option (Remark)
UO VSN
/TCHNG OFLOW=ACK
*
*ON %END CONTINUE
*
* The above ON statement will ensure that when the user terminates CFS with an END
* or * command, the procedure mode will continue automatically with the
* statement following the *DIA statement. (Shutdown Command sequence,
* see the following page).
*
* Switch to Dialog mode.
*DIA

The above Startup file section will be automatically executed after CFS has been loaded. As soon as the *DIA statement has been processed, CFS will switch the input medium to the terminal.

The procedure will only regain control when the user terminates CFS by pressing the K1 key, or by entering one of the following commands: END, *, /DO ..., /CALL ..., /LOAD ..., /EXEC ..., or /LOGOFF. The procedure can also be reactivated by entering a RET command.

After returning to the procedure, the Startup file section following the *DIA statement will be executed.

*
* Controlled Termination of CFS (Shutdown).
*
*002 FILE=NO
*WRITE 'Termination Processing'
*PROMPT &SM,'Should the Command Memory be saved ? (Y/N, DUE1 = Y)'
*IF &SM = 'N' SKIP .CONEND
* Save the Command Memory.
*
* The following two statements are necessary at this point, even
* though they already appeared in the first section of the Startup
* File. This is because the user may have called CFS procedures that
* may in turn have redefined the &SUFFIX procedure variable.
*
*&SUFFIX = &LOGNAM
*IF &SUFFIX = '' &SUFFIX = &ACCT
*
SM CFS.MEM.&SUFFIX
.CONEND
*&N=0
.LOOP
*&CON='CON'&N
*IF &&CON = '' SKIP .CON1
* (Connection n not open)
*IF &&CON = '$DIALOG' SKIP .CC1
* (Connection to $DIALOG)
DC&N
*SKIP .CON1
.CC1
CC&N.B
* (Continue in Conn. &N + Break)
LOGOFF NOSPOOL
.CON1
*&N=&N+1
*IF &N<10 SKIP .LOOP
.END
* Terminate CFS
END

This example illustrates a Startup file with a Shutdown Command Sequence for CFS. The Shutdown Command Sequence consists of the portion following the *DIA statement.

A further example of a Startup file can be found on page 18-.