Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Naive PL/1 F question.
I've a naive question about the PL/1 F we
have onboard on MVS3.8j. Forgive me, I'm trying to write code for going from a single character to its EBCDIC code and viceversa. The first problem should be solved by this code fragment: ECODE: PROCEDURE ( CHR ) RETURNS(FIXED BIN(15)); DCL CHR CHARACTER(1); DCL CODE FIXED BIN(15); CODE = UNSPEC ( CHR ); RETURN ( CODE ); END ECODE; which seems to work correctly. But I can't see a way for going back from the EBCDIC code to a single character string, using only PL/1 F. For what I can understand in modern PL/1 compilers there are specific builtin functions implemented, but, reading the original IBM manuals, I can't see any simple way to solve the problem. Any advice? Peppe. |
On Tue, 7 Jul 2020, Peter Jansen via groups.io wrote:
Isn't UNSPEC not also a pseudo-variable, so that it can also be used on the left-hadYep, it does. Unfortunately, FIXED BIN(15) is half word, i.e. two bytes in PL/1 F. My guess UNSPEC ( CHR ) = CODE convert just the most significant CODE byte, leading to a wonderful ZERO character. If I got it right, this routine should do the trick: ECHAR: PROCEDURE ( CODE ) RETURNS(CHARACTER(1)); DCL CODE FIXED BIN(15); DCL CHR CHARACTER(1); DCL B BIT(16); B = UNSPEC(CODE); UNSPEC(CHR)=SUBSTR(B,9,8); RETURN ( CHR ); END ECHAR; Wondering if there are better ways. Peppe. |
On Tue, 7 Jul 2020, Giuseppe Vitillaro wrote:
On Tue, 7 Jul 2020, Peter Jansen via groups.io wrote:Well, this is actually a little bit better:Isn't UNSPEC not also a pseudo-variable, so that it can also be used on the left-hadYep, it does. ECHAR: PROCEDURE ( CODE ) RETURNS(CHARACTER(1)); DCL CODE FIXED BIN(15); DCL CHR CHARACTER(1); UNSPEC(CHR)=SUBSTR(UNSPEC(CODE),9,8); RETURN ( CHR ); END ECHAR; I guess the UNSPEC(CHR) can't be moved inside the RETURN statement? It doesn't work for what I've verified. Peppe. |
Ed Liss
Try the following code
toggle quoted message
Show quoted text
//HERC01P JOB MSGCLASS=A,MSGLEVEL=(1,1)??????????? //P1? EXEC PL1LFCG???????????????????????????????? //PL1L.SYSIN DD *????????????????????????????????? ?TEST:PROC OPTIONS(MAIN);????????????????????????? ????? DECLARE 1 NUM_CHAR??????? FIXED BINARY(15),? ????????????? 1 CHAR_2???? DEFINED NUM_CHAR,?????? ??????????????? 2 (CHAR_HIGH,CHAR_LOW)???????????? ?????????????????????????? CHAR(1);??????????????? ????? NUM_CHAR=0;????????????????????????????????? ????? CHAR_LOW = 'A';????????????????????????????? ????? PUT SKIP LIST(NUM_CHAR,CHAR_LOW);??????????? ????? PUT SKIP LIST('NUMBER','CHAR');????????????? ????? DO NUM_CHAR=240 TO 249;????????????????????? ???????? PUT SKIP LIST(NUM_CHAR,CHAR_LOW);???????? ????? END;???????????????????????????????????????? ?END TEST;???????????????????????????????????????? If you submit it, this is what you get: ????? 193?????????????? A NUMBER????????????????? CHAR ????? 240?????????????? 0 ????? 241?????????????? 1 ????? 242?????????????? 2 ????? 243?????????????? 3 ????? 244?????????????? 4 ????? 245?????????????? 5 ????? 246?????????????? 6 ????? 247?????????????? 7 ????? 248?????????????? 8 ????? 249?????????????? 9 On Tue, Jul 7, 2020 at 03:04 AM, Giuseppe Vitillaro wrote:
I've a naive question about the PL/1 F we |
On Tue, 7 Jul 2020, Ed Liss wrote:
Try the following codeIf I got it right not different from a C union. Nice trick ;-) Thanks, Peppe. |
to navigate to use esc to dismiss