please help me write this subroutine and sub-module:
1. An subprogram receives 5 parameters
- CHAR VAR String with max. 200 bytes length
- Table with unknown number of elements Index lower limit 1, elements CHAR (01)
- BIN FIXED (15) (for current table size)
- Table with unknown number of elements Index lower limit 1, elements PIC '9'.
- BIN FIXED (15) (for current table size)
Task of the subroutine:
- transfer all digits of the 1st parameter to table2 (4th parameter)
- ignore all blanks
- transfer remaining characters to table1 (2nd parameter)
- in parameters 3 and 5 the current number of table elements is to be stored in each case
how to Code the subprogram, am ok with cobol but pl1 confuses me and i have no time to sit and debug
2. Function with parameter transfer
An external function PRUEF receives a CHAR VAR string as parameter and shall check whether this string complies with the following rules:
- the length of the string may be max. 18 bytes
- the first character must be an asterisk (*) or a sign (+ or -)
- the rest may only consist of digits and a maximum of one dot
return value of the function is one BIT. If the above rules are followed, the function returns '1'B to the calling program, otherwise '0'B is returned.
Example of a possible call to PRUEF:
DCL ZK CHAR (15) VAR;
DCL PRUEF ENTRY RETURNS (BIT);
...
IF PRUEF (ZK) THEN CALL SUB2;
ELSE CALL ERROR;
Code the complete function!
3. Pointer arithmetic
DCL EVENT-NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
In a loop using pointer arithmetic, output each character of the variable EVENT NAME one at a time and count the number of 'O' characters.
. . . . .
DCL NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL CHAR1 CHAR(1);
DCL CNT1 FIXED BIN(15);
DCL XCHAR BIN FIXED(15);
CNT1 = 0; /* do not forget to initialize the counter before counting!!! */
DO XCHAR = 1 TO LENGTH(NAME) ; /* scan index along the string NAME */
CHAR1 = SUBSTR(NAME, XCHAR, 1); /* extract single character, for clarity */
IF CHAR1 = ‘O’ THEN DO; /* check for super-character ‘O’ */
CNT1 = CNT1 + 1; /* count one more ‘O’ when found */
PUT SKIP DATA(CHAR1, CNT1); /* debug print */
END;
END;
. . . . /* output of required results */
. . . . .