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



Jon's version is the one I posted (I believe). I sent it to you a few months
ago. It is the version of strsep that I posted early today to the list.


Bob Cozzi
Cozzi Consulting
www.rpgiv.com


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Rusling, John B. (Alliance)
Sent: Thursday, June 12, 2003 12:20 PM
To: 'rpg400-l@xxxxxxxxxxxx'
Subject: Re: strtok and consecutive delimiters

I attended a Paris/Gantner training session a few months ago.

Jon indicated he had a version of strtok that properly handled "empty
fields".

I suggest contacting him about your problem, if, as Scott suspects below,
that is the problem you are having.

John B.


-----Original Message-----
From: rpg400-l-request@xxxxxxxxxxxx

------------------------------

message: 2
date: Thu, 12 Jun 2003 10:41:47 -0500 (CDT)
from: Scott Klement <klemscot@xxxxxxxxxxxx>
subject: Re: strtok and consecutive delimiters


On Thu, 12 Jun 2003, Wayne Achenbaum wrote:
>
> Hello all, I have a procedure in a service pgm that uses the strtok
> function. I am trying to figure out how to handle consecutive delimiters.
I
> attended a session with Jon Paris  that had a handout the Power of
> Prototyping. In the session we talked about using the function. I remember
> him saying with slight modification the code could handle consecutive
> delimiters. Does anyone know how handle the multiple delimiter issue??
>


Unfortunately, the strtok() function has no way of detecting "empty
fields" (i.e. places where there are two consecutive delimiters).  I think
that's what you're asking.

In FreeBSD and other Unixes, strtok() has been deprecated in favor of
strsep() for this very reason.   here's a quote from the FreeBSD manual
page for strsep():


   HISTORY
     The strsep() function is intended as a replacement for the strtok()
     function.  While the strtok() function should be preferred for
     portability reasons (it conforms to ISO/IEC 9899:1990 (``ISO C89''))
     it is unable to handle empty fields, i.e. detect fields delimited by
     two adjacent delimiter characters, or to be used for more than a single
     string at a time. The strsep() function first appeared in 4.4BSD.


My opinion is that functions like strtok and strsep don't save a lot of
work.  It's just as easy to write your own routine that copies characters
until it finds a delimiter -- and that way you can make it easier to use
from RPG.


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





As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.