|
*OMIT doesn't make a parameter "optional". *OMIT means you can pass the special value of *OMIT. *NOPASS == optional. You can chose to pass something or not pass anything.
I think you are splitting hairs here, especially as in my original post I said I was using *OMIT
When you pass *OMIT to an RPG IV procedure, what you are really doing is passing a NULL pointer.I am not sure that is true. In the called procedure you test the field's address for NULL, not its value.It is indeed true. In RPG you test if %addr(someParm) = *NULL;
My apologies, I read "passing a NULL pointer" as "passing a NULL value"
Not sure I understand what you are saying. The RPG prototype specified an int or the C prototype?
Both! That was the problem. The RPG correctly had INT and the C one incorrectly also had INT. When I changed the C one to be a pointer to INT I could use a NULL in the C code. regards Stephen Osborn Financial Messaging & Integration Misys Banking Systems +44 (0)20 8486 1790 stephen.osborn@xxxxxxxxx
-----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Wilt, Charles Sent: 01 November 2006 17:45 To: RPG programming on the AS400 / iSeries Subject: RE: Calling an RPG procedure with optional parameters from C code-----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Osborn, Stephen Sent: Wednesday, November 01, 2006 11:35 AM To: RPG programming on the AS400 / iSeries Subject: RE: Calling an RPG procedure with optionalparameters from CcodeRPG doesn't allow optional parameters to be specified before required ones either.That is true for *NOPASS but not for *OMIT*OMIT doesn't make a parameter "optional". *OMIT means you can pass the special value of *OMIT. *NOPASS == optional. You can chose to pass something or not pass anything.When you pass *OMIT to an RPG IV procedure, what you are really doing is passing a NULL pointer.I am not sure that is true. In the called procedure you test the field's address for NULL, not its value.It is indeed true. In RPG you test if %addr(someParm) = *NULL; Since you are dealing with parameters passed by reference, you are asking if the pointer passed in is NULL. Note that *OMIT only works with parameters passes by reference. You can't use it for parameters passed by VALUE whereas you can use *NOPASS for parameters passed by reference or by value.Thus, in your C/C++ program just make sure you pass aNULL pointerfor the *OMITted parameter.I tried that, before I asked a question here, and it didn'twork. Theprocedure prototype said that an INT is being passed as the first parameter and when I specified a NULL there the module would not compile.Not sure I understand what you are saying. The RPG prototype specified an int or the C prototype?However I just changed the first parameter of the procedureprototypeto be pointer to INT and now NULL is acceptable and it isnow working.As RPG, by default, uses pass by reference, in a Cprocedure prototypethe declarations should be of type 'pointer to xxx'. All the other fields in my C procedure prototype were 'pointer to xxx' sothat onewas probably just a typo.This makes sense and is what I was saying. If your RPG proto looks like D myproc pr D parm1 10i 0 options(*OMIT) D parm2 10i 0 options(*OMIT) D parm3 10i 0 Or D myproc pr D parm1 10i 0 D parm2 10i 0 D parm3 10i 0 Then in either case, your C prototype should look like (please excuse any typos, been 10+ years since I wrote any C) void MYPROC (int *parm1, int *parm2, int *parm3) C will allow you to pass a NULL point for any of the 3 parameters. HTH, Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121
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.