|
>Date: Wed, 20 Sep 2000 00:03:53 GMT
>From: booth@martinvt.com
>
>... why do I want to use
>
>"CallP Sleepfor('00:30:00')"
>
>instead of
>
>"Call 'SleepFor'"
>"Parm '00:30:00' Parm8 8"
Booth, here are some of the main reasons for preferring
callp over call are. Assume that SleepSeconds takes a
numeric parameter with the number of seconds:
1. the compiler will check your parameters for you, ensuring
that you pass enough, and that they are the right types
C callp SleepSeconds ('00:30:00')
==> Error: incorrect parameter 1 for SleepSeconds
2. you can code an expression as a CALLP parameter
C callp SleepSeconds (numHours * 60 * 60)
3. the compiler will fix up your parameters for you
if it can (say you pass packed, and the procedure
wants zoned, it will handle it for you as long
as the parameter is defined as CONST or VALUE.)
D SleepSeconds PR EXTPGM('SLEEPSECS')
D seconds 6p 0 CONST
D numSecs1 S 5p 0
D numSecs2 S 10i 0
C callp SleepSeconds (numSecs1)
C callp SleepSeconds (numSecs2)
Both the packed and integer parameter will be valid,
and the procedure will receive the parameter the way
you said you wanted it in the prototype: packed(6,0)
If you use CALL, the compiler wouldn't care, but one
of the calls would get a decimal-data error.
4. you can often change some of the details of the called
program or procedure without changing any of the
calling code. For example, say you would rather this
be a procedure instead of a program; you just change
the prototype and recompile all the callers. You don't
have to change the code of callers at all because the
compiler will handle calling procedure SLEEPSECONDS
instead of program SLEEPSECS because the prototype tells
it what to do. If you do change it in a way that requires
the callers's code to change, the compiler will tell you.
D SleepSeconds PR
D seconds 6p 0 CONST
5. using CALLP, you can reduce the number of variables in your
program. In your example above, you don't really need
variable Parm8.
Barbara Morris
+---
| 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-2025 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.