I understood the difference in calling methods but I had implemented it
incorrectly.

In both my RPG & C prototypes I had an INT, whereas I should have had an INT
in the RPG one and a pointer to INT in the C one.

Once I had corrected the C prototype I was able to pass NULL and get it
working.


regards

Stephen Osborn
Financial Messaging & Integration
Misys Banking Systems
+44 (0)20 8486 1790
stephen.osborn@xxxxxxxxx
 

-----Original Message-----
From: c400-l-bounces+stephen.osborn=misys.com@xxxxxxxxxxxx 
[mailto:c400-l-bounces+stephen.osborn=misys.com@xxxxxxxxxxxx] 
On Behalf Of Scott Klement
Sent: 01 November 2006 17:35
To: C programming iSeries / AS400
Subject: Re: [C400-L] Calling an RPG procedure with optional 
parameters from C code


RPG (by default) passes parameters by reference.  C (by 
default) passes 
parameters by value.   To pass a parameter by reference from 
C, you put a 
pointer on the prototype, and you pass the address of a 
variable to that pointer.

RPG's *OMIT is equivalent to passing a NULL pointer.

So, from C, you simply pass NULL instead of a variable.  For example:


prototype:

void procname(char *param1, char *param2, char *param3, char *param4);

code:

    char val1[50], val2[50], val3[30], val4[50];

// set the "val" variables to useful values here

    procname( val1, NULL, val3, val4);

    - or -

    procname( NULL, val2, val3, val4);


etc, etc.

--
Scott Klement  http://www.scottklement.com

On Wed, 1 Nov 2006, Osborn, Stephen wrote:

I have RPG procedures where the first two parameters are 
alternates, i.e.
values must be supplied for
param1, param3, param4, etc
or
param2, param3, param4, etc

Using *OMIT I can call these in either mode from RPG, e.g.
callp procname(value1 : *OMIT : value3 : value4) or callp 
procname(*OMIT : value2 : value3 : value4)

However I need to call some of these routines from some 
legacy C code.


How do I specify in C (both the prototype and the code) 
that param1 & 
param2 can be *OMIT'd?


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.