You can write a complete AMB program in S-COBOL. There are no differences between S-COBOL and batch COBOL in the Identification, Environment, and Data Divisions. The major differences exist in the Procedure Division.
S-COBOL reserved words are the same as ANSI COBOL, plus the following. For a complete list of all AMB reserved words and symbols, see the Help topic Reserved Words.
The following are the S-COBOL structures.
ENTRY |
Establish entry point for subprogram. |
ESCAPE |
Exit from the current paragraph. |
EVALUATE |
Evaluate conditions; program a decision table. |
EXIT PROGRAM |
End the execution sequence. |
PERFORM |
Execute a particular paragraph or section, with or without arguments. |
REPEAT |
Establish a loop for testing. |
SEARCH |
Establish looping or conditionals for each WHEN. |
STOP RUN |
Return control to the operating system. |
TRUE/FALSE |
Establish true and false flags; test the flags. |
UNTIL/WHILE |
Form a loop with a test. |
USERNAME |
Title a procedure generated by the Precompiler. |
AT END/INVALID KEY |
Test for end-of-file or invalid key condition. |
EVALUATE |
Evaluate one or more conditions; program a decision table. |
IF/ELSE-IF/ELSE |
Evaluate one or more conditions. |
SEARCH |
Establish looping or conditionals for each WHEN condition. |
TRUE/FALSE |
Establish true and false flags; test the flags. |
AT END/INVALID KEY |
Test for end-of-file or invalid key condition. |
TRUE, FALSE, ALWAYS, NEVER |
Use these AMB-supplied flags for testing. |
TRUE/FALSE |
Establish true and false flags; test the flags. |
TRUE, FALSE, ALWAYS, NEVER |
Use these AMB-supplied flags for testing. |
REPEAT |
Establish a loop for testing. |
UNTIL/WHILE |
Form a loop with a test. |
ENTRY |
Establish entry point for subprogram. |
ESCAPE |
Exit from the current paragraph. |
EXIT PROGRAM |
End the execution sequence. |
STOP RUN |
Return control to the operating system. |
REGISTER = " THIS IS A VERY," ... && "VERY LONG LITERAL"
Type of Comparison | Relational Operator |
---|---|
Greater than |
IS GREATER THAN IS > |
Not greater than |
IS NOT GREATER THAN IS NOT > IS <= |
Less than |
IS LESS THAN IS < |
Not less than |
IS NOT LESS THAN IS NOT < IS >= |
Equal to |
IS EQUAL TO IS = |
Not equal to |
IS NOT EQUAL TO IS NOT = |
Greater than or equal to |
>= |
Less than or equal to |
<= |
Abbreviated Syntax | S-COBOL/COBOL Equivalent |
---|---|
A = B |
MOVE B TO A |
A B = C |
MOVE C TO A B |
A = B + C |
COMPUTE A = B + C |
B = B + C |
COMPUTE B = B + C |
A = B - C |
COMPUTE A = B - C |
A = B * C |
COMPUTE A = B * C |
A = B / C |
COMPUTE A = B / C |
A = B + (C * D) |
COMPUTE A = B + (C * D) |
A <+ B |
COMPUTE A = A + B |
A </ B |
COMPUTE A = A / B |
A << B |
MOVE B TO A |
A <* B |
COMPUTE A = A * B |
001030 PARA PAYROLL-CALCULATION /*PARAGRAPH NAME 001040 IF EMPLOYEE-TYPE = 'HRLY' 001050 IF HOURS-WORKED > 40 001060 HOURS-BASE = HOURS-WORKED * 2 001070 HOURS-BASE = HOURS-BASE - 40 001080 ELSE 001090 HOURS-BASE = HOURS-WORKED 001100 GROSS-PAY = HOURS-BASE * HOURS-RATE 001110 ELSE 001120 GROSS-PAY = EMPLOYEE-SALARY
Because IF conditions generally require an alternative action, you generally code an ELSE-IF or ELSE statement at the same level of indentation as the IF.
Line: 1040
001040 IF EMPLOYEE-TYPE = 'HRLY'
If EMPLOYEE-TYPE is not equal to HRLY, control passes to the corresponding ELSE statement on line 1110. On the other hand, if EMPLOYEE-TYPE is equal to HRLY, lines 1050-1100 execute.
Lines: 1050 - 1120
001050 IF HOURS-WORKED > 40 001060 HOURS-BASE = HOURS-WORKED * 2 001070 HOURS-BASE = HOURS-BASE - 40 001080 ELSE 001090 HOURS-BASE = HOURS-WORKED 001100 GROSS-PAY = HOURS-BASE * HOURS-RATE
If EMPLOYEE-TYPE is equal to HRLY, lines 1050-1100 execute. In this case, if HOURS-WORKED is not greater than 40, control passes to the ELSE statement at the same indentation (line 1080). Thus, lines 1060-1070 execute only for hourly employees who have worked over 40 hours, while line 1090 executes for hourly employees who have worked 40 hours or less.
Line:
001110 ELSE 001120 GROSS-PAY = EMPLOYEE-SALARY
Executes for employees who are not hourly.