-----Original Message-----
From: c400-l-bounces@xxxxxxxxxxxx [mailto:c400-l-bounces@xxxxxxxxxxxx]On
Behalf Of Simon Coulter
Sent: Friday, October 01, 2004 11:00 PM
To: C programming iSeries / AS400
Subject: Re: [C400-L] RE: Passing parameter back to calling CL

>> But it does seem like you guys are going through a lot of gyrations to
>> do something very simple:  get a return value from a C program.  All
>> you want is a number, so return one:

> In this particular case he wants to return a numeric value. But that is
> simply a specific instance of the generic "returning parameters"
> problem which C does not do well and for which most C programmers think
> there is no solution because "Why would you want to do that?". The only
> reason they think that way is because you can't do that sort of thing
> in Windoze or Eunuchs.

If you think about it there is a good reason to isolate the program from the
OS. Variables that are passed as arguments to a function ( or as400
program ) are constructed by the caller.  That means the caller has to
follow the same rules for the representation of data as the function being
called.  Since every language represents the data in its variables
differently, how is the OS supposed to know how to setup the arguments to be
passed to a C program differently than an RPG one?  Should arrays be null
terminated?  are members of a struct packed or aligned on word boundaries?
If a C++ program is being called, should there be a virtual function table
associated with the class object that is being passed by reference?

> The C-weenie solution to this defect is most
>likely to populate a stream file with the data (write to file in
>program B and read the 'return' value in program A).

I am sure unix has the same, but I know windows weenies make use of DLLs in
a fashion that provides similar if not superior functionality of OS400
programs and service programs.  The windows DLL function is made accessible
with two simple function calls, LoadLibrary and GetProcAddress.   What is
nice about DLLs is they can be easily hooked, resulting in the programmer
having a lot of control over the behavior of the DLL.  Wouldnt it be nice if
an RPG program did all its database data management thru a service program
and the programmer could hook those service program calls?  Possibly use the
hooks to implement something like a DDM file.

-Steve



This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2019 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].