Variabletransfer via based structure



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

Variabletransfer via based structure

Postby Gustav » Mon Mar 21, 2022 1:31 pm

Hey guys
I have the following probem and I hope someone can please help me:

I have two programs: The main one (Program1) calls the second programm (Program2) and hand over up to 3 varibles (maybe variable1 and variable2 or variable1, variable1 and variable3 .
By the way my call differs from the normal way of PL/I calling, but is in my eyes not necessary to explain it ...

Main programm:

[...]
call(program2, Variable1, Variable2, Variable3)
 


These 2 respectively 3 variables are read out by a based structure in programm2.


DCL VARIABLE4 char (1) BASED (Variable1);
DCL VARIABLE5 char (1) BASED (Variable2);
DCL VARIABLE6 char (1) BASED (Variable3);


 


The position of the passed variables is read out (passed variable1 corresponds to the created variable4, variable 2-->variable5, etc.). However, this does not work via the normal procedure based on the position to position but via "based" structure. The program expects until now always that all 3 variables are filled. But I want that the 3rd parameter is expected to be variable. i.e. if only variable1 and variable2 are passed, only variable 4 and 5 should be supplied with values; variable6 remains empty, but is still declared.

If all three Varibalen (Variabe1 - Varibale6) are filled, these are taken over in variable 4 - variable 6).
This is because the created variable6 is still used in the program code of the subprocedure, even if it was not passed. There is a possibility to get the quantity of filled variables (in the if clause shown as quantity), which can be used.

Probably this construct is cumbersome and there are simpler/better solutions. A rebuilding/change of the whole structure is however not possible/desired/wanted.


Symbolically a program code as it unfortunately did not function:


DCL VARIABLE4 char (1) BASED (Variable1);
DCL VARIABLE5 char (1) BASED (Variable2);
If quantity = 3
then do;
DCL VARIABLE6 char (1) BASED (Variable3);
END;
else do;
DCL VARIABLE6 char (1) init('');
END;
 



I hope you understand the pseudocode and what I mean, because in reality it's much more complicated :cry:

Thany you for your advice
Gustav
 
Posts: 7
Joined: Wed May 06, 2020 1:50 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Variabletransfer via based structure

Postby prino » Mon Mar 21, 2022 8:18 pm

By the way my call differs from the normal way of PL/I calling, but is in my eyes not necessary to explain it ...

No, you don't because we're all blessed with mind-reading capabilities! You're a total timewaster!

And you cannot base something on a variable, only on a pointer or the address of a variable. And DCL statements in "IF-THEN-ELSE" statements? Ever thought about RTFM?

Show the real code, and not some made-up incomprehensible bogo-trash.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 629
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