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



The EXPORT on these lines is the problem.

D BCDPacked S 18P 0 EXPORT
D BCDChar S 10 EXPORT

Without the EXPORT, the variables would be global to a particular module. With
EXPORT, they are
global to the entire service program. Thus, you can't have them defined in
more than one place.

One option:
Use EXPORT on the definitions in one module and IMPORT on all the others.

It looks like the C module may be using the EXPORTED variables for input; since
the procedures only
have one parameter and don't return any values.

WHY??? This is not a very good way to do this. Can you change the C
procedures to "properly" handle
input/output?

I'd do something like so:

//PCS_Format Include file
DToBCD PR like(t_BCDPacked)
D charInput const like(t_BCDChar)

DFromBCD PR like(t_BCDChar)
D numInput const like(t_BCDPacked)

D t_BCDPacked S 18P 0 based(TEMPLATE)
D t_BCDChar S 10 based(TEMPLATE)


Then to use, simply copy in the include file:
/Copy *LIBL/QCPYSRC,PCS_Format (contains prototypes just as above)

Define some variables for yourself:
D myBCDPacked like(t_BCDPacked)
D myBCDChar like(t_BCDChar)

And use them when calling the C procedures:
C EVAL myBCDPacked = FromBCD(myBCDChar)


If you can't change the C procedures, I'd strongly recommend wrapping the C
procedures in RPG IV
procedures which have "proper" inerfaces. Holler if you need help doing so.


Charles




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
mgarton@xxxxxxxxxxxxxxx
Sent: Thursday, June 07, 2007 10:17 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Service Program using a C module




I have a program that format messages. Currently the
formatting process is all in one program that uses a C
module. Since the formatting can be used by other processes,
I want to make a formatting service program with a
module for each message type. The C module would be used
within all the
modules. I am getting multiple definition errors when trying
to create the service program. Below is how the C module is
described/used in the existing program.

DToBCD PR
D 18P 0
DFromBCD PR
D 10
D BCDPacked S 18P 0 EXPORT
D BCDChar S 10 EXPORT

C CALLP ToBCD(BCDPacked)

Here is how the service program modules look:

/Copy *LIBL/QCPYSRC,PCS_Format (contains prototypes just as above)

D BCDPacked s 18P 0 Export
D BCDChar s 10 Export

P FMT0100 B Export

D FMT0100 PI 256A
D InputVar 264A Const


C CALLP ToBCD(BCDPacked)

P E

This is my first attempt at creating a service program from
scratch. How
should the variables BCDPacked and BCDChar be described?
The above works
when I have the one module but when I start adding other
modules I get a multiple definition error when I try to
create service program. So that means that the variables are
global when described as above? Is there a better way to do this?

Thanks.


Mark Garton
Information Systems
O'Reilly Auto Parts

--
This is the RPG programming on the AS400 / iSeries (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




This e-mail transmission contains information that is intended to be
confidential and privileged. If you receive this e-mail and you are not a
named addressee you are hereby notified that you are not authorized to read,
print, retain, copy or disseminate this communication without the consent of
the sender and that doing so is prohibited and may be unlawful. Please reply
to the message immediately by informing the sender that the message was
misdirected. After replying, please delete and otherwise erase it and any
attachments from your computer system. Your assistance in correcting this
error is appreciated.


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.