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



Hi John,

Your getToken() routine is calling the ILE C strtok() routine. You can tell that because of the extProc('strtok') on the prototype.

<rant>
a) This is why I don't like renaming stuff with extproc. There's really no value to it, and it confuses people -- or at least delays them

b) I also don't like strtok() in general. It's so easy to write your own that works better -- why insist on using one that doesn't quite work the way you want?!
</rant>

Anyway, the problem is that you are passing %addr() to the strtok() routine instead of passing the strings. That means that RPG isn't given the opportunity to null-terminate them.

You see... when you define a prototype with options(*string), you can pass the parameter two ways. (a) You can just pass a pointer, in which case the options(*string) has no effect, or (b) you can pass the field itself, in which case RPG creates a temporary copy and adds a null-terminator to the end to make it compatible with C.

The problem in your code is that it's not compatible with C. There's no null-terminator. Options(*string) can't add one, because you're passing a pointer, instead of passing the string itself.

I'm going to go over your code and fix it up, and post my results. Give me a few minutes to do that...


On 2/19/2010 12:43 PM, Kelly, John (Limerick) wrote:
I did change the loop to a DoU but ended up with the same result.

As a novice to this whole area I am struggling to identify where the
getToken subprocedure. Attached please find the full code for the get
email/set email utility. My thoughts are that it is part of the QC2LE
binding directory, and is related to the Strtok C function.

The string the utility needs to process is a series of emails,
separated by a semi colon. It is to keep processing until it finds a
space which determines it has found all the email addresses. An example
of the string it is attempting to read would be ...

'john.wayne@xxxxxxxxxx;joe.blogs@xxxxxxxxxx'

In the attached code it sets the 'delimiters' variable to include both
a semi colon and a space - i.e. '; '. It then uses it to interrogate the
string using the gettoken procedure.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Needles,Stephen J
Sent: 19 February 2010 16:35
To: RPG programming on the IBM i / System i
Subject: RE: Help with Service Programming

Yep...that's it...thanks Dennis.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dennis Lovelady
Sent: Thursday, February 18, 2010 5:40 PM
To: 'RPG programming on the IBM i / System i'
Subject: RE: Help with Service Programming

If I remember correctly Dow will always perform 1 extra iteration.
Try
changing the DOW to a DoU.

Rather than

doW (pToken<> *null);

try

doU (pToken = *null);

The above is incorrect. Difference between DoU and DoW is that DoU will
always do one iteration (the test is at the end), while DoW test is at
the
beginning, so it will not process the (potentially) extra step. Neither
operation will iterate an extra time after the test.

The problem is almost certainly in the getToken procedure. May we see
that,
please?

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Some see the problem in every opportunity, some see the opportunity in
every problem."
-- Kevin Cowling






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.