HPlogo Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 3 Program Development

Control Codes (JCWs)

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

A Job Control Word (JCW) is one word (16 bits) of memory used to pass information between job steps and to determine the status of the previous job step. Figure 3-5 “Job Control Word (JCW) Structure” shows the structure of a JCW. It is composed of a 2-bit type and a 14-bit modifier.

The space allowed for JCWs is determined by the space allowed for your session or job after file equations, temporary files, and data space is taken. There is always one system JCW and one user-defined JCW named CIERROR that is actually defined by Command Interpreter (CI). You can define as many user-defined JCWs as remaining space allows.

You can use the MPE/iX command :SHOWJCW to see the value of JCWs. If you have not defined any JCWs of your own, this shows only the value of the system JCW and CIERROR.

Figure 3-5 Job Control Word (JCW) Structure

[Job Control Word (JCW) Structure]

System JCW

The system JCW is set by MPE/iX and some subsystems. You can set the system JCW programmatically by using intrinsics or interactively at the Command Interpreter (CI) level by using the :SETJCW command.

MPE/iX checks the system JCW before each step (process) in a session or job is executed. Based on the system JCW value, MPE/iX may abort the session or job. You can interactively check the system JCW at the CI level by using the :SHOWJCW command. You can programmatically check by intrinsics (calling :FINDJCW) or by using an :IF/THEN, :ELSE, :ENDIF construct.

The system JCW type provides information on the severity of an error. The modifier can be set to identify the cause or to pass information to subsequent job steps. However, information placed there by the user may not be preserved, because MPE/iX can change it. Thus it is frequently expedient to place information that you want preserved in a user-defined JCW instead of in the system JCW. When set by the user, the modifier may be modified by MPE/iX. The types are the bit settings given below, accompanied by their keywords, and descriptions.

00:OK No error occurred in the previous step. 01:WARN An unusual event occurred, but not necessarily fatal. 10:FATAL Program aborts, under its own control. 11:SYSTEM System aborts user process due to a problem outside the process's direct control.

The modifier can be set to any number from 0 to 65535, inclusive. These numbers are divided up for use by each of the four types given above:

     OK      0-16383
     WARN    16384-32767
     FATAL   32768-49151
     SYSTEM  49152-65535

JCW Notation

A JCW value can be described with three kinds of notation:

  • A keyword, followed by a constant. The constant is the decimal equivalent of the octal number in the modifier.

  • Modifier appended to the type to form one constant.

  • The numerical value of the modifier.

Figure 3-6 “JCW Notation Examples” shows examples of JCW notations.

Figure 3-6 JCW Notation Examples

[JCW Notation Examples]

Using a System JCW

The following job shows an example of using a system JCW:

   :JOB STUDENT.INTRO/PASSWORD
   :CONTINUE
   :FTNXL ABC
   :IF   JCW<FATAL THEN
   :     LINK $OLDPASS,ABCPROG
   :     SAVE ABCPROG
   :     RUN ABCPROG
   :ELSE
   :     SAVE $OLDPASS,ABCOBJ
   :ENDIF
   :SHOWJCW
   :EOJ

This job compiles an HP FORTRAN 77/iX program. If it works, you want to link the object file to your program file and run the program. If a problem occurs during the compile, you want to save the file and end the job.

If an error occurs, HP FORTRAN 77/iX sets JCW = FATAL, so the job tests the value of the JCW against the value FATAL (FATAL is the same as FATAL0 or 32768). The :CONTINUE command causes the job to proceed even if the next step produces an error. The :IF/THEN, :ELSE, :ENDIF structure allows you to make a decision based on the JCW value following the :FTNXL job step. The system-defined JCW that CI creates is called CIERROR. CI sets the JCW modifier to the last CI error number. Sometimes, CI aborts a job based on the value of the CIERROR modifier.

User-defined JCWs

User-defined JCWs allow you to supply input to programs by using Command Interpreter (CI) and get status from programs that can be examined in CI. Characteristics of user-defined JCWs include:

  • Available to each process in the same session or job.

  • Have names different from JCW or CIERROR.

  • Are created and set interactively with :SETJCW or programmatically with the PUTJCW intrinsic.

  • Can be examined interactively with :SHOWJCW or programmatically with the FINDJCW intrinsic.

MPE/iX does not examine user-defined JCWs. The value of a user-defined JCW has meaning only to the user. Keywords and definitions assigned to the type and modifier can be identical to those assigned to system JCWs or different. You determine what action to take based on your own definitions.

Using a User-defined JCW

The following job shows an example of using a user-defined JCW.

     :JOB STUDENT.INTRO/PASSWORD
     :SETJCW UPDATE=OK
     :RUN UPDATEDB
     :IF UPDATE=OK THEN
     :    RUN REPORT
     :ELSE
     :    SHOWJCW
     :    TELLOP REPORT NOT RUN
     :    TELLOP TOO MANY INPUT ERRORS
     :ENDIF
     :EOJ

In this example, the job stream begins by defining and setting a user-defined JCW called UPDATE to the value OK ( OK is the same as OK0 or 0). Running the program named UPDATEDB edits a database. If too many errors occur, UPDATEDB changes the value of UPDATE by using the PUTJCW intrinsic. The :IF/THEN, :ELSE structure tests the value of UPDATE. If the program is successful (in other words, if there are not too many errors), it runs another program called REPORT. If too many errors did occur in the UPDATEDB program, the job shows the JCW values, sends two messages to the console operator, and ends.