× 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.


  • Subject: Re: Having problems accessing IFS from RPGIV
  • From: Jon.Paris@xxxxxxxxxx
  • Date: Fri, 14 Jan 2000 14:36:45 -0500



 >> Do you mind providing a link to this book if it is online?

I have included the link in the Notes section below the table.

 >> And where would I go to find out if IBM would mind?

Since it is based on my own teaching material I have retained the rights to
"derivative works" so derive away <g>  I have made some changes to the narrative
below so it has been "derived" once already. The table won't show up properly
here but you can get the basic idea.  There are some other items that should
probably be added - I'll let others comment.  Feel free to put this on the site.

Correspondence of C and RPG IV data types
C              RPG IV                Comments

int, long      10I 0 Value           See note 1
unsigned int   10U 0 Value           See note 1
double          8F   Value           See note 1
char           10U 0 Value           See note 2
short          10I 0 Value           See note 2
int *          10I 0                 See note 3
unsigned *     10U 0                 See note 3
double   *      8F                   See note 3
char *           *   Value           Options(*String) can also be used see note
4
void *           *   Value           See note 3
(*)              *   Value ProcPtr        See note 5


Notes:

The Redbook "Who knew you could do that with RPGIV ?" (SG24-5402-00)
has a more complete version of these notes together with examples.
You can find this book at the following link
but note that this will change when the book is published.
www.redbooks.ibm.com/redpieces/abstracts/sg245402.html

1. The normal method of parameter passing on the AS/400 is known as "by
reference". This means that a pointer to the data item is passed to the called
routine, not the actual data itself. C on the other hand passes parameters "by
value" that is the data itself is passed to the caller. In order for RPG to
correctly pass such parameters the keyword VALUE must be coded on the
prototype. See also Note 3.

2. In theory, char (which is a single byte character) should be represented in
RPG IV as 1A and short (which is a short integer) as 5I 0. In practice however
it is usually necessary to code such parameters as 10U 0 for char and 10I 0.

3. C classifies its pointers by the type of data to which it "points". So int *
represents a pointer to an integer data item. RPG IV does not differentiate
pointers in this way so all RPG data pointers are equivalent to the C void *
definition. As noted above, C expects parameters to be passed by value.
However, passing a field "by reference" and passing a pointer to that field "by
value" are equivalent. Since passing a parameter by field name rather than by
using %Addr(fieldname) is somewhat more intuitive to most people we
have used this notation in the table.  There is an example that demonstrates
this point in the Redbook.

4. C does not really have the concept of a fixed length character string in the
way
that RPG does. Most C functions expect strings to be variable in length and
terminated by a null character (hex ?00?). RPG IV prototypes support the
OPTIONS(*STRING) parameter to simplify the programmers life when
interfacing to such routines. Use of this option allows the programmer to
specify either a field name or a pointer for the parameter. If a field name is
used, the compiler generates code to move the field to a temporary area, add
the null terminator, and then pass the address of this temporary area as the
parameter.

5. The keyword PROCPTR is used to qualify an RPG pointer (*) definition when
the parameter in question is a procedure pointer. These are required by some
C functions (for example bsearch and qsort which are demonstrated in the
Redbook).


+---
| 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 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.