|
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. ------------------------------
As an Amazon Associate we earn from qualifying purchases.
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.