Page 1 of 1

Convert string to procedure or variable

PostPosted: Fri Mar 12, 2021 2:19 pm
by Gustav
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

Re: Convert string to procedure or variable

PostPosted: Fri Mar 12, 2021 6:30 pm
by sergeyken
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.

Re: Convert string to procedure or variable

PostPosted: Sat Mar 13, 2021 4:47 am
by prino
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.