Convert string to procedure or variable



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

Convert string to procedure or variable

Postby Gustav » Fri Mar 12, 2021 2:19 pm

Hi everybody,

I have the following problem and I hope a smart guy can help me :? , because I have nothing found in the web...

I have a select statement, like in the following example. Depending on the case I call a procedure, which has general statements and case-specific ones. This procedure is called in every case. I do not want to devide this proc in many procs, but I like to to something like call proc !! 'E1' for case 1, call proc !! 'E2' for case two and so on, how you can see in the procSUN example. The reason is that if there is a case E3 and E4 in future I have to expand the select statements and not the "under procs"..
I hope my examples were understandable.

Do you know a smart solution to convert a string to a procedure or variable?


Select-Statements:

select (E);
when (E1)
Vaiable= 'E1';
call ProcSUN;
when (E2)
Vaiable= 'E2';
call ProcSUN;
otherwise action-n;
end;

ProcSun procedure

ProcSUN:

...general Statements...
call proc !! Variable

end ProcSUN
Gustav
 
Posts: 7
Joined: Wed May 06, 2020 1:50 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Convert string to procedure or variable

Postby sergeyken » Fri Mar 12, 2021 6:30 pm

1. Learn how to use code tags.

2. What this stands for???
 call proc !! Variable


3. In any compiled language, any procedure call is resolved BEFORE the execution begins. Hence, a variable procedure name is a kind of nonsense. PL/I is not a computer game.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 408
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: Convert string to procedure or variable

Postby prino » Sat Mar 13, 2021 4:47 am

sergeyken wrote:2. What this stands for???
 call proc !! Variable


Codepage issue, and you should have guessed as much.

sergeyken wrote:3. In any compiled language, any procedure call is resolved BEFORE the execution begins. Hence, a variable procedure name is a kind of nonsense. PL/I is not a computer game.


You can do this using fetch with the "title" option,

or

you can pass the procedure to be called as an entry variable,

or

you can use label variables and goto,

or

you can subscripted labels.

In PL/I you can do most things in at least three ways. Here you have four.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times


Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post