× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

*OMIT will pass a NULL-Pointer to your procedure. In your procedure you need
to check the incoming parameter being NULL or not.
If MyPar <> *NULL;
//Parameter passed
EndIf;

To pass a parameter with *OMIT you need to add the keyword OPTIONS(*OMIT) to
your prototype.
D MyProc PR
D client_number LIKE ( REF_client_number ) Options(*OMIT)
D client_type LIKE ( REF_client_type ) Options(*OMIT)

I only use *OMIT if there are parameters somewhere in the middle of my
parameter list when I want to distinguish if a default value or nothing is
passed.
For Optional parameters I prefer OPTIONS(*NOPASS), that means you either can
call the procedure with 2,3 or 4 parameters.

D MyProc PR
D MyFile Like(FldRef.File) Const
D MyLib Like(FldRef.Lib) Options(*NoPass) const
D MyMbr Like(FldRef.Mbr) Options(*NoPass) const

These procedure can be called with 1, 2 or 3 parameters:
MyProc('MyFile);
MyProc('MyFile': 'MyLib');
MyProc('MyFile': 'MyLib': 'MyMbr');

If your procedure you need to check the number of incoming parameters with
the built-in-Function %Parms;
The parameter can only be accessed if passed. If you try to access a
parameter that is not passed you'll get error MCH3601.

If %Parms >= 3;
//Parameters incl.Member are passed
ElseIf %Parms >= 2;
//Parameters incl.Lib are passed
Else;
//Only file is passed
EndIf;

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von David FOXWELL
Gesendet: Friday, 21. August 2009 11:18
An: RPG programming on the IBM i / System i
Betreff: OPTIONS(*OMIT)/style question

Hi all,

I am often finding that I am declaring a local variable just so I can call
another procedure. In that case, the called procedure wouldn't use the
variable. I see other programmers who don't declare the variable but just
pass 0 or ' ' or *BLANK, etc.

Example

D client_type S LIKE ( REF_client_type )

client_number = 1;
MyProc (
client_number :
client_type );


Instead of :

client_number = 1;
MyProc (
client_number :
' ' );

I don't like this method as I often see this kind of thing :

MyProc (
client_number :
' ' :
0 :
client_info :
more_client_info :
' ' :
);

Here one can only presume that the parameters with ' ' or 0 aren't used. In
my first example, I can see that client_type isn't initialised so isn't
being used, although it probably still needs a comment. Also when I declare
the local variable, I use the same reference field that is used in the
prototype.
D MyProc PR
D client_number S LIKE ( REF_client_number )
D client_type S LIKE ( REF_client_type )



I just wondered if this is what *OMIT is for?

MyProc (
client_number :
*OMIT :
*OMIT:
client_info :
more_client_info :
*OMIT :
);

Thanks.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.