|
Thanks for the info. I was looking for info on how to do this and use the created functions IN ANY ILE Program (Without copying the subprocedure source into the pgm).
So for your example, after creating a srvpgm containing the procedure "ShowMsg", how can I invoke the ShowMsg function in other programs?
-----Original Message-----
From: Buck Calabro [mailto:buck.calabro@aptissoftware.com]
Sent: Thursday, July 13, 2000 12:51 PM
To: rpg400-l@midrange.com
Subject: RE: How to create my own built-in functions
Joel Stone wrote using HTML:
>I want to create my own built-in functions,
>to be used in any ILE program.
AMEN!
>I think I want a combination of sub-procedures,
>binding directories, service programs, activation
>groups, etc.
>
>I cant seem to find an article that puts them
>all together in a VERY simple example.
>Does anyone know of such an article in
>Midrange Computing or News/400?
There have been scads of articles; I'm not certain there exists one very
simple example of all the elements you mentioned. There's a lot of
complexity there! Aside from the oft mentioned Redbook (Who knew you could
do that with RPG?) there may not be a single repository of that information.
It seems that the typical example of a user defined function is the call to
QCMDEXEC. Being me, I will avoid that!:
* QRPGLESRC mbr(DSPLY)
H debug dftactgrp(*no) actgrp('QILE') option(*srcstmt: *nodebugio)
* dbgview(*list)
* Display a message to the user
D rc s 10u 0
D ShowMsg pr 10u 0
D MsgText 50 const
D MsgQueue 10 const
C eval rc = ShowMsg('Test': 'BUCK')
C eval *inLR = *On
P ShowMsg b Export
D ShowMsg pi 10u 0
D MsgText 50 const
D MsgQueue 10 const
D rc s 10u 0
C MsgText Dsply MsgQueue 99
C If *In99 = *On
C Eval rc = -1
C Else
C Eval rc = 0
C EndIf
C Return rc
P ShowMsg e
This compiles with option 14 off of PDM, so it qualifies as a simple example
- no special binding, etc. but it shows the procedure prototype (the PR),
the actual procedure code (flanked by the P specs, including the PI). It
also shows local variable usage (rc within the procedure) and how to invoke
the function (eval rc=ShowMsg...)
The only special thing I do is to use the Windows "copy" function to copy
the "dbgview(*list)" before I exit SEU. When I compile, I put 14 in the
option field, newline to the command line and "paste" it there before
pressing Enter. That way I don't have to prompt every compile and I can
compile it on any machine without having to modify CRTBNDRPG.
As I said, this is a simple enough example. If you want to have some fun
with it, we can turn this into a mini-tutorial on how to learn ILE. (This
example is more like "How to learn RPG IV.")
Buck Calabro
Aptis; Albany, NY
"We are what we repeatedly do.
Excellence, then, is not an act, but a habit." --Aristotle
Billing Concepts Corp., a NASDAQ Listed Company, Symbol: BILL
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.