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.
PL1 subroutine help
-
- Posts: 8
- Joined: Sat Jul 24, 2021 10:04 pm
- Skillset: cobol db2
- Referer: internet
- prino
- Posts: 641
- Joined: Wed Mar 11, 2009 12:22 am
- Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
- Referer: Google
- Location: Vilnius, Lithuania
- Contact:
Re: PL1 subroutine help
Q: What have you tried yourself?
A: Nothing, I'm waiting for someone to do my work for me!
A: Nothing, I'm waiting for someone to do my work for me!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
robert.ah.prins @ the.17+Gb.Google thingy
-
- Posts: 8
- Joined: Sat Jul 24, 2021 10:04 pm
- Skillset: cobol db2
- Referer: internet
Re: PL1 subroutine help
am a python guy, hv no mf editor to try. learning slowly and then to understand using python. takes more time
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: PL1 subroutine help
grasshopper wrote:am a python guy, hv no mf editor to try. learning slowly and then to understand using python. takes more time
It looks like your problem is not in transition from Python (or whatever else) to PL/I (or whatever else).
Your problem is in lack of logical thinking, and zero level of experience in algorithm design, as important parts of any IT education. If those two problems were not the case, the transition from ANY language to ANY OTHER one would be a piece of cake.
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 8
- Joined: Sat Jul 24, 2021 10:04 pm
- Skillset: cobol db2
- Referer: internet
Re: PL1 subroutine help
for question #3.
3. Pointer arithmetic
DCL EVENT-NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
here is my code, but i cnnot execute, can someone verify this please????
/code/
DCL CHAR2 CHAR(1);
DCL CNT1 FIXED BIN(15);
PTR = addr(EVENT-NAME);
DO
PTR = PTR BY 1 TO LENGTH(EVENT-NAME)
IF CHAR1 = ‘A’ THEN CNT1 = CNT1 + 1;
PUT SKIP DATA(CHAR1, CNT1);
END;
/code/
3. Pointer arithmetic
DCL EVENT-NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
here is my code, but i cnnot execute, can someone verify this please????
/code/
DCL CHAR2 CHAR(1);
DCL CNT1 FIXED BIN(15);
PTR = addr(EVENT-NAME);
DO
PTR = PTR BY 1 TO LENGTH(EVENT-NAME)
IF CHAR1 = ‘A’ THEN CNT1 = CNT1 + 1;
PUT SKIP DATA(CHAR1, CNT1);
END;
/code/
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: PL1 subroutine help
1) variable names CANNOT include minus sign (unlike COBOL)
2) Variables PTR and EVENT_NAME must be declared before usage
3) Pointer variables are physical addresses, they cannot be used as array indexes, or integer variables, or whatever else except the base address of a based variable
4) etc, etc, etc……..
2) Variables PTR and EVENT_NAME must be declared before usage
3) Pointer variables are physical addresses, they cannot be used as array indexes, or integer variables, or whatever else except the base address of a based variable
4) etc, etc, etc……..
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: PL1 subroutine help
Hint:
To work with characters of a text string there is no need of based variables. Use string manipulation functions, like SUBSTR, and others.
RTFM, RTFM, and RTFM!!!
To work with characters of a text string there is no need of based variables. Use string manipulation functions, like SUBSTR, and others.
RTFM, RTFM, and RTFM!!!
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 8
- Joined: Sat Jul 24, 2021 10:04 pm
- Skillset: cobol db2
- Referer: internet
Re: PL1 subroutine help
my case study is to use pointers only for this.
will this work?
/code
DCL NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
DCL CNT1 FIXED BIN(15);
PTR = addr(NAME);
DO
I = 1 BY 1 TO LENGTH(NAME) ;
PTR = PTR+1;
IF CHAR1 = ‘O’ THEN CNT1 = CNT1 + 1;
PUT SKIP DATA(CHAR1, CNT1);
END;
/code
will this work?
/code
DCL NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
DCL CNT1 FIXED BIN(15);
PTR = addr(NAME);
DO
I = 1 BY 1 TO LENGTH(NAME) ;
PTR = PTR+1;
IF CHAR1 = ‘O’ THEN CNT1 = CNT1 + 1;
PUT SKIP DATA(CHAR1, CNT1);
END;
/code
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: PL1 subroutine help
grasshopper wrote:my case study is to use pointers only for this.
will this work?
/code
DCL NAME CHAR(50) VAR INIT('TOKYO-OLYMPICS-TOKYO');
DCL PTR POINTER;
DCL CHAR1 CHAR(1) BASED(PTR);
DCL CNT1 FIXED BIN(15);
PTR = addr(NAME);
DO
I = 1 BY 1 TO LENGTH(NAME) ;
PTR = PTR+1;
IF CHAR1 = ‘O’ THEN CNT1 = CNT1 + 1;
PUT SKIP DATA(CHAR1, CNT1);
END;
/code
This cannot work at all!
Please, read carefully my notes to your previous posts, regarding the difference between pointers, and indexes!
Please, use code tags when presenting your code!
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: PL1 subroutine help
Code: Select all
. . . . .
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 */
. . . . .
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 7574
-
by sergeyken
View the latest post
Mon Jul 26, 2021 5:53 am