Re: Calling RPGILE program from C

<chrish-lbwoW8fqX/3W0OUqm4st0/d9D2ou9A/[email protected]>
Newsgroups gmane.comp.lang.as400.c
Organization Shield Advanced Solutions Ltd
Message-ID <[email protected]>
Sorry about the last message, I had a different ID set up so when I sent in
replies nothing was showing up! Now you have the latest code which should
work! The passing of a pointer to the RPG program is what I am questioning.
If you actually want to send in the value use the following

decimal(10,0) len;

len = *(decimal(10,0)*)argv[2];


Chris...
 

-----Original Message-----
From: C400-L [mailto:c400-l-bounces-Zwy7GipZuJhWk0Htik3J/[email protected]] On Behalf Of
chrish-lbwoW8fqX/3W0OUqm4st0/d9D2ou9A/[email protected]
Sent: October 29, 2014 9:48 AM
To: 'Bare Metal Programming IBM i (AS/400 and iSeries)'
Subject: Re: [C400-L] Calling RPGILE program from C

Here is the code that should work. (Sorry had the wrong declaration for the
decimal pointer.)

#include <stdio.h>
#include <string.h>
#include <decimal.h>
#include <stdlib.h>

#pragma linkage(RGTRIGCNTL,OS)
void RGTRIGCNTL(char *, decimal(10,0)*);

int main(int argc, char **argv)
{
decimal (10,0) *len;

len = (decimal(10,2)*)argv[2];
    RGTRIGCNTL(argv[1],len);
}

I assume you are passing a decimal into the program and are sending a
pointer to the RPG program??  If no you need to get the contents of the
argv[2] parameter and pass as a value.
-----Original Message-----
From: C400-L [mailto:c400-l-bounces-Zwy7GipZuJhWk0Htik3J/[email protected]] On Behalf Of Tony Cate
Sent: October 28, 2014 4:02 PM
To: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
Subject: [C400-L] Calling RPGILE program from C

First the code:

*#include <stdio.h>*
*#include <string.h>*

*#include <decimal.h>
#include <stdlib.h>

typedef void RGTRIGCNTL(char[80], decimal(10,0));

#pragma linkage(RGTRIGCNTL,fetchable)

int main(int argc, char *argv[])
{
    char                *triggerInfo;
    decimal (10,0)      triggerLen;

    triggerInfo = argv[1];
    triggerLen = argv[2];

    RGTRIGCNTL(triggerInfo, &triggerLen);
}*

*What's going on: trying to write a small C program to attach to file
triggers.*

Problems:

pragma linkage won't allow 'OS' for a parameter. Everything I've read
indicates that's what I want. The only "ID' compiler didn't barf on is
'fetchable', which is why its there.

It compiles, but nothing happens when I try to step into RGTRIGCNTL.

The Dev box is V5R4 (long story).

The questions:

Why can't I use 'OS' in linkage? Why isn't my program getting called?

The last time I wrote a C program was in college, a looong time ago.
--
*Tony Cate* | Senior Programmer/Analyst | 704.872.2458 x 126
[image: Auction Edge, Inc.] <http://www.auctionedge.com/> *AUCTION EDGE,
INC.* | *Powering Independent Auctions* STATESVILLE, NC | 704.872.2458
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.

--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L)
mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.

-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.