IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Call a PL/1 module using Variable name


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Fri Feb 12, 2010 10:34 am
Reply with quote

Hi! Folks
Help me out in the following.

'PGMNAME' is the name of a PL/1 module.
Code:
SOURCE = 'PGMNAME';
CALL SOURCE;

I checked in the manuals, it seems like, I will be only able to call a PL/1 modules, if I only pass the Program name directly to the call.

Is it possible to call the PL/1 module 'PGMNAME' using SOURCE?
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Fri Feb 12, 2010 11:23 am
Reply with quote

See FETCH
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Wed Feb 17, 2010 2:07 pm
Reply with quote

Even Fetch requires the actual Program name of PL/1.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 17, 2010 2:09 pm
Reply with quote

did You look at the declare part of the manuals ?
that' s where the issue is explained!
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Feb 18, 2010 4:51 pm
Reply with quote

I checked http://publibfp.boulder.ibm.com/epubs/pdf/ibm3pg70.pdf

In that XINFO in Page 74. I found this

For instance, given the program:

Code:
defs: proc;
dcl (b,c) ext entry;
dcl x ext fixed bin(31)
init(1729);
dcl y ext fixed bin(31) reserved;
call b(y);
fetch c;
call c; end;


Here we are still declaring the external entities and calling the Program by name and not by variable name.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 18, 2010 6:25 pm
Reply with quote

I can guarantee that it is possible to do it !
I should have a sample somewhere, if I can find it I will post it...

I do not remeber the exact syntax but it was an array of subroutines names
and they were called according to some kind of record type...

something along the lines of ( check the syntax on the manuals anyway)
Code:
DCL 1 RECORD,
  2 RECTYPE FIXED BIN(31)
  2 .....
  2 ..... ;

DCL FARRAY(....) EXTERNAL INIT('a,'b,'c',.....);
........
READ .... 
   CALL FARRAY(RECTYPE) ......
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Thu Feb 18, 2010 10:46 pm
Reply with quote

Sure, enrico-sorichetti.
I will be counting on you.

Would be of great help, if the following is achieved.
'PGMNAME' is the name of a PL/1 module.

Code:
SOURCE = 'PGMNAME';
CALL SOURCE;

Provided I don't define the PGMNAME as an external entity, because in my requirement I will get to know the program to be called in the runtime.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 19, 2010 1:56 am
Reply with quote

Hi Hameed!

sorry for having given misleading info, the fingers were faster than the brain
or I execeeded my allowable multiprogramming level

the array I had ben working with/talking about was not an array of pli procedure names,
it was an array of pointers to assembler subroutines entry points
which was dynamically filled by a small assembler stub.

probably, the same result could be obtained for pl/1 procedures, but it would need a bit of investigation
and a study of the ASM to PL/I interlanguage communication facilities.

sorry again for the wrong info
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Fri Feb 19, 2010 10:46 am
Reply with quote

enrico-sorichetti, you need not feel sorry.
Most of the time, the guys in the forum have helped with exact answers.
So, I will not be disappointed for this.
Back to top
View user's profile Send private message
kiran.zadbuke

New User


Joined: 13 Aug 2008
Posts: 1
Location: India

PostPosted: Fri Mar 05, 2010 6:19 pm
Reply with quote

Helllo Hameed,

Please declare your variable as below in program,

DCL SOURCE ENTRY VARIABLE;
DCL PGMNAME ENTRY EXTERNAL;

SOURCE = PGMNAME;

CALL SOURCE;


Please try above code. Thanks!

Cheers,
Mr.Kiran
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Mar 05, 2010 10:38 pm
Reply with quote

kiran.zadbuke wrote:
Please declare your variable as below in program,

DCL SOURCE ENTRY VARIABLE;
DCL PGMNAME ENTRY EXTERNAL;

SOURCE = PGMNAME;

CALL SOURCE;

Please try above code.


Great way to make your presence know on these fora, giving an answer that is completely and utterly wrong. You might want to read the initial posting again, try to understand the question and only then reply.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Sat Mar 06, 2010 3:44 am
Reply with quote

If you can use a very short assembler program, i believe there is a way to declare a function based on a pointer. Then you just LOAD (SVC 6) the program using assembler (passing in the name) and call it from the PL/I program. Been many years since I used PL/I (over 25) so this may not be accurate, but the theory is sound icon_rolleyes.gif .I used a PL/I-like language for many years that did this quite well - I don't know if PL/I itself does it. Of course, this is for dynamic loads, not statically linked subroutines. For statically linked, you'd need to use addr() and some sort of table lookup.

Note that if you dynamically load and run programs, be aware of the security implications. Don't allow someone to just pass in a program name and run it. That is an easily exploited security hole.

Disclaimer: Sorry, but this is all conjecture at the end of a very long week. I haven't looked anything up or done any research.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Mar 06, 2010 3:57 am
Reply with quote

From the PL/I Language Reference V3R9M0 (SC27-1460-09):

Code:
dcl A entry;
dcl B entry ext('C');
dcl T char(20) varying;

T = 'Y';

fetch A title('X'); /* X is loaded */
fetch A;            /* A is loaded */
fetch B title('Y'); /* Y is loaded */
fetch B;            /* C is loaded */
fetch B title(T);   /* Y is loaded */
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top