The easy answer is that it probably does a TRIM prior to the fold.
Thus the all-spaces field becomes null, and the fold cannot work on a
zero length field. And its not a problem, only a curiousity. I
discovered it while looking for garbage in production records, making
use of LES in order to compare for any character less than char(31).
Found a bunch, too!
j
On 5/26/06, john reid <[EMAIL PROTECTED]> wrote:
Not sure how spaces enter into it, although I see that it yields the
same in the following with or without spaces.
j
0001 EXECUTE 'CT JMRBP TEST.FOLD'
0002 A = "A B C D E F G H I"
0003 CRT LEN(A)
0004 CRT 'A:':A
0005 B=FOLD(A,1)
0006 CRT 'LEN B:':LEN(B)
0007 CRT 'B:':B
0008 A="ABCDEFGHI"
0009 CRT LEN(A)
0010 CRT 'A:':A
0011 B=FOLD(A,1)
0012 CRT 'LEN B:':LEN(B)
0013 CRT 'B:':B
0014 STOP
17
A:A B C D E F G H I
LEN B:17
B:A~B~C~D~E~F~G~H~I
9
A:ABCDEFGHI
LEN B:17
B:A~B~C~D~E~F~G~H~I
On 5/25/06, Brad Davis <[EMAIL PROTECTED]> wrote:
> Your're right - a kosher fold should search from the end of each line
> back to the break character and break on the length of the line, only if
> it can't find the break character...
>
> -----Original Message-----
> From: George Gallen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 25, 2006 2:47 PM
> To: u2-users@listserver.u2ug.org
> Subject: RE: [U2] FOLD can mutilate
>
>
> I use the following:
>
> SUBROUTINE FMTTEXT(DATA,MAXLEN,BRKCHAR)
> *
> * FMTTEXT - TEXT FORMATTER WITH LINE BREAKS BETWEEN WORDS.
> *
> * 01/04/95 GMG INITIAL PROGRAMMING
> ********************************************************************
> *
> NEWLINE=""
> CONVERT CHAR(254) TO CHAR(253) IN DATA
> NODL=DCOUNT(DATA,@VM)
> FOR T=1 TO NODL
> IF DATA<1,T>[LEN(DATA<1,T>),1]#"-" THEN DATA<1,T>=DATA<1,T>:" "
> IF LEN(DATA<1,T>)<=MAXLEN THEN GOTO 30
> FOR L=MAXLEN TO 1 STEP -1
> IF DATA<1,T>[L,1]=BRKCHAR THEN
> IF DATA<1,T+1>="" OR T=NODL THEN
> INS "" BEFORE DATA<1,T+1>
> NODL=NODL+1
> END
> DATA<1,T+1>=DATA<1,T>[L+1,LEN(DATA<1,T>)]:DATA<1,T+1>
> DATA<1,T>=DATA<1,T>[1,L]
> GOTO 30
> END
> NEXT L
> 30:
> DATA<1,T>=TRIM(DATA<1,T>)
> NEXT T
> RETURN
> END
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Behalf Of Brad Davis
> > Sent: Thursday, May 25, 2006 2:27 PM
> > To: u2-users@listserver.u2ug.org
> > Subject: RE: [U2] FOLD can mutilate
> >
> >
> > Ok just for the record: here's the completed code:
> > SUBROUTINE FOLDX(STR,LENG)
> > FOR I=1 TO LENG
> > POS=(LENG*(I-1))+1
> > NEW<-1>=TRIMB(TRIMF(STR[POS,LENG]))
> > NEXT I
> > STR=NEW
> > RETURN
> >
> > Or, here's a more complicated idea:
> > SUBROUTINE FOLDX(STR,LENG)
> > FOR I=1 TO LENG
> > POS=(LENG*(I-1))+1
> > CHR=STR[POS+LEN,1]
> > IF CHR=" " THEN
> > NEW<-1>=TRIMB(TRIMF(STR[POS,LENG]))
> > END ELSE
> > *fold back to space if possible
> > END
> > NEXT I
> > STR=NEW
> >
> > -----Original Message-----
> > From: Brad Davis
> > Sent: Thursday, May 25, 2006 1:04 PM
> > To: u2-users@listserver.u2ug.org
> > Subject: RE: [U2] FOLD can mutilate
> >
> >
> > POS=(LENG*(I-1))+1
> >
> > -----Original Message-----
> > From: Brad Davis
> > Sent: Thursday, May 25, 2006 11:40 AM
> > To: u2-users@listserver.u2ug.org
> > Subject: RE: [U2] FOLD can mutilate
> >
> >
> > If fold cannot find a space to break on, what does it do? I think it
> > breaks the fold length, so it can break a string.
> >
> > You can also write your own fold statement.
> >
> > SUBROUTINE FOLDX(STR,LENG)
> > FOR I=1 TO LENG
> > POS=???
> > NEW<-1>=TRIMB(TRIMF(STR[POS,LENG])
> > NEXT I
> > RETURN
> >
> >
> > -----Original Message-----
> > From: john reid [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, May 25, 2006 9:52 AM
> > To: list
> > Subject: [U2] FOLD can mutilate
> >
> >
> > Anyone notice the length problem on the fold of spaces?
> >
> > TEST.FOLD
> > 0001 EXECUTE 'CT JMRBP TEST.FOLD'
> > 0002 A = SPACE(10)
> > 0003 CRT LEN(A)
> > 0004 CRT 'A:':A
> > 0005 B=FOLD(A,1)
> > 0006 CRT 'LEN B:':LEN(B)
> > 0007 CRT 'B:':B
> > 0008 STOP
> > 10
> > A:
> > LEN B:-1
> > B:
> >
> >
> > --
> >
> > john
> > -------
> > u2-users mailing list
> > u2-users@listserver.u2ug.org
> > To unsubscribe please visit http://listserver.u2ug.org/
> > -------
> > u2-users mailing list
> > u2-users@listserver.u2ug.org
> > To unsubscribe please visit http://listserver.u2ug.org/
> > -------
> > u2-users mailing list
> > u2-users@listserver.u2ug.org
> > To unsubscribe please visit http://listserver.u2ug.org/
> > -------
> > u2-users mailing list
> > u2-users@listserver.u2ug.org
> > To unsubscribe please visit http://listserver.u2ug.org/
> -------
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
> -------
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
>
--
john
--
john
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/