` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Par2: Extracting strings from text
2001-11-25 -- Ray Goudie
 
>What would be a smart way loop through a textfield (CSTRING(4001)) >extracting 80 character long rows and avoiding to split words? I had to do the same thing, a number of years ago. Here is some quick-and-dirty code that will achieve what you are looking for. It only splits on spaces. --- ROW_WIDTH equate(80) textField cstring(4001) rowText cstring(ROW_WIDTH + 1) textLength ushort startPosition ushort ndx ushort code !!! textField gets set somehow. textLength = len(textField) startPosition = 1 endPosition = ROW_WIDTH loop !!! Fetch default row width. rowText = sub(textField, startPosition, ROW_WIDTH) !!! Consider the first character of the next row. if textField[startPosition + ROW_WIDTH] <> ' ' !!! Reduce length of row while the last character of the current row is not a space. !!! Any characters at the end of the current row belong with characters at the !!! beginning of the next row. ndx = ROW_WIDTH loop while rowText[ndx] <> ' ' ndx -= 1 until ndx = 1 end rowText = clip(sub(rowText, startPosition, ndx)) !!! To clip trailing space(s). do processRow !!! Set start position for the next row. startPosition += ndx until startPosition > textLength --- Hope I didn't miss anything.


Today is November 21, 2024, 6:57 am
This article has been viewed 35200 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: