|
Jon: I wondered if anyone would mention strtok(), very handy function. I'd been looking at using it to parse strings for embedded quotes. First thought was to wrap each returned token in quotes and add that result to a result string rebuilding it token by token. But I quickly discarded that thought because strtok() apparently skips consecutive delimiters making it unsuitable when the original string contains consecutive quotes. Too bad because it could make a nice, straightforward procedure otherwise. ...Unless you know how to circumvent that behavior? Tom Liotta rpg400-l-request@midrange.com wrote: > 7. Removing punctuation (not using arrays) (Jon Paris) > >I have a routine that uses the C function strtok to perform exactly this >task. This is just the "raw" code - I would wrap it as a subprocedure but >it works nicely. It is not too long so I will include it here. > >D Token@ S * >D Delims C '.,:;" ' // put whatever >characters you want eliminated here >D EditedField S 100a Varying > : : : > EditedField = ''; // Set work field to null > > Token@ = StrTok( Address : Delims ); // Get first token > If Token@ <> *Null; > EditedField = %Str(Token@); > > DoW Token@ <> *Null; // Process second & subsequent tokens > Token@ = StrTok( *Null : Delims ); > If Token@ <> *Null; > EditedField = EditedField + Space + %Str(Token@); > EndIf; > EndDo; > EndIf; > > Address = EditedField; // Copy edited field back to original > >This is the prototype I use for strtok. You'll need to specify bind dir >QC2LE on the compile. If you want to understand how it works there is a >similar example in the RPG Redbook. > > D StrTok Pr * ExtProc('strtok') > D String@ * Value Options(*String) > D Delimiters@ * Value Options(*String) -- -- Tom Liotta The PowerTech Group, Inc. 19426 68th Avenue South Kent, WA 98032 Phone 253-872-7788 x313 Fax 253-872-7904 http://www.powertechgroup.com __________________________________________________________________ The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.