************************************************************************** * DBG041R4: Format text lines - parse line into words. * Copyright (C) 2000 Martin Rowe <martin@dbg400.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ************************************************************************** H DATEDIT(*YMD) DEBUG(*YES) OPTION(*NODEBUGIO : *SRCSTMT) ************************************************************************** * Output text 50 lines of upto 132 characters D P#Out s 132 dim(50) ************************************************************************** * DATA STRUCTURES ************************************************************************** * Input data in chunks of entry length D #a s 5 0 D #b s 5 0 D #c s 5 0 D #d s 5 0 D NoMore s 1 D P#In s 132 D P#RtnEnt s 3 0 ************************************************************************** * ENTRY PARAMETERS ************************************************************************** C *ENTRY PLIST C PARM P#In Text entry C PARM P#RtnEnt Returned entries C PARM P#Out Returned data ************************************************************************** * MAINLINE PROGRAM ************************************************************************** * Field initialisation C EVAL #a = 0 No of input entries C EVAL #b = 1 actual text length C EVAL #c = 1 trailing blanks C EVAL #d = 0 leading blanks C EVAL NoMore = *off C CLEAR P#Out Returned data * Split the input string into seperate words B001 C 1 DO 50 #a * Quit if no more to process B002 C IF NoMore = *on C LEAVE E002 C ENDIF * Reset start position to next non-blank character C ' ' CHECK P#In:#b #c 70 * If non-blank not found, we can leave now B002 C IF *IN70 = *off C EVAL NoMore = *on * Otherwise need to extract to next blank within return length X002 C ELSE C ' ' SCAN P#In:#c #d 70 B003 C IF *IN70 C EVAL P#Out(#a) = %SUBST(P#In:#c:(#d-#c)) E003 C ENDIF E002 C ENDIF * Set up final number of return entries C EVAL P#RtnEnt = #a * Set up start point for next word search C EVAL #b = #d E001 C ENDDO * C RETURN **************************************************************************