Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable in CALLB 1

Status
Not open for further replies.

TracyV

Programmer
Nov 24, 2003
35
US
Is it possible to use a variable when using CALLB? Depending on the selection, i want to CALLB different programs. Not sure if this is a subprocedure thing, not realy familiar with those yet. Any suggestions would be greatly appreciated!!

 
Use a prototype and put the variable as the EXTPGM keyword (I'm assuming that anything you call with this prototype has the the same types and number of parameters as the prototype definition).

Code:
     D Prg_Name        S             10A
     D Parm1           S             10A   
     D Parm2           S             10A   


     	 //  Prototype for variable program                             
     D Call_Something  PR                  Extpgm(Prg_Name)
     D Parm1                         10A      
     D Parm2                         10A   
      /Free     

         Select;
         When One_Thing;
           Prg_Name = 'PGMA';
         When Another_Thing;
           Prg_Name = 'PGMB';
         Endsl;
         
         Parm1 = 'Whatever';
         parm2 = 'You_Want';

         Call_Something(Parm1:Parm2);
      /End-Free

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
Thank you for your posting, it was quite helpful!

I have a question regarding the code you supplied. If I understand correctly, this code does a 'CALL' to the desired program. Is it possible to do a 'CALLB' rather than a 'CALL'?
 
CALLB is actually oobsolete; CALLP (or using the prototype as in my example) should work just fine.

IBM said:
The recommended way to call a program or procedure (written in any language) is to code a prototyped call.

See


Feles mala! Cur cista non uteris? Stramentum novum in ea posui!
 
I'm having problems calling modules, it looks like i need to use Extproc instead of Extpgm. Extproc is not allowing me to use a variable for the program name. I'd have to setup a different prototype for each call? What i am doing is reading a file which contains a selection and a program name. I load these into an array and want to populate the call structure with the program name from the file. These objects are compiled as modules rather than programs.
 
TracyV;

If you have ever read much written by Bob Cozzi you might remember that he very strongly says "You call programs and procedures, not modules". The design of binding modules at compile time is as obsolete as the CallB opcode. I would suggest that you use FlapEyre's suggestion and perhaps take a look at your design process as well.
 
Alan is correct.

You did say "programs", not "modules" in your original post. There is no way of which I am aware of to call a variable procedure name. You will have to use Select/When/Endsl and do it that way. Or make these modules individual bpund programs and use a prototype with EXTPGM (where you can use a variable name).


Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top