On Tue, 4 Nov 2003, Tom Conlin wrote:

never mind it was the [] not the ()

> works with this tiny change
>
> from
>         ADD-FILLER (10 - length? FORMATTED-LINE)             ;; 3333
> to
>
>         ADD-FILLER  10 - (length? FORMATTED-LINE)
>
>
>
> this is because  10 - length?
>
> is being asked to happen before length? FORMATTED-LINE
>
> and is  not evaulating to an integer! so ADD-FILLER does not see it's
> argument
>
> hope that helps
>
>
>
> On Tue, 4 Nov 2003, Steven White wrote:
>
> >
> > This must be something really dumb, but I am wondering if perhaps I am
> > not understanding how something works.
> >
> > The purpose of the script below is to go through a block of blocks (a
> > little "file" of "records" in my native tongue) and, for each record,
> > rearrange the "fields" with some spaces in them, suitable for
> > displaying.  It builds up this displayable line in the item called
> > FORMATTED-LINE.
> >
> > On line 1111 of the script, the first item (number four = "THIS") is
> > added to FORMATTED-LINE, and on line 2222 the FORMATTED-LINE is
> > displayed to show that it is correct.  On line 3333, a procedure is
> > called to fill the line out to 10 spaces.
> >
> > In the procedure to add the spaces, at line 4444, suddenly
> > FORMATTED-LINE is different; it contains the field just added, PLUS the
> > data the is not due to be added until line 5555.  In other words, on
> > line 2222 FORMATTED-LINE is "THIS" and on line 4444 it is "THISIS", but
> > the IS is not supposed to be added until line 5555, AFTER the script has
> > returned from adding the spaces after THIS.
> >
> > Am I losing my mind or what?
> >
> > Thank you.
> >
> > Steven White
> > [EMAIL PROTECTED]
> > script follows--may be cut, pasted, and run:
> >
> > REBOL [
> > ]
> >
> > DATA-SELECTED: [
> >     [ "TEST" "A" "IS" "THIS" ]
> >     [ "WORK" "THIS" "WON'T" "WHY" ]
> > ]
> >
> > DATA-FORMATTED: none
> > FORMATTED-LINE: none
> >
> > TEST-PROCEDURE: does [
> >     DATA-FORMATTED: copy ""
> >     foreach DATA-RECORD DATA-SELECTED [
> >         FORMATTED-LINE: copy ""
> >             PRINT ["APPENDING " FOURTH DATA-RECORD]
> >         append FORMATTED-LINE fourth DATA-RECORD             ;; 1111
> >             PRINT ["FORMATTED LINE NOW IS " FORMATTED-LINE]  ;; 2222
> >         ADD-FILLER (10 - length? FORMATTED-LINE)             ;; 3333
> >  ;;;;;;;;   PRINT ["APPENDING " THIRD DATA-RECORD] ;; UNCOMMENTING
> > GIVES ERROR
> >         append FORMATTED-LINE third DATA-RECORD              ;; 5555
> >             PRINT ["FORMATTED LINE NOW IS " FORMATTED-LINE]
> >         ADD-FILLER (20 - length? FORMATTED-LINE)
> >         append FORMATTED-LINE second DATA-RECORD
> >         ADD-FILLER (30 - length? FORMATTED-LINE)
> >         append FORMATTED-LINE first DATA-RECORD
> >         append FORMATTED-LINE newline
> >         append DATA-FORMATTED FORMATTED-LINE
> >     ]
> > ]
> >
> > ADD-FILLER: func [
> >     "Add a specified number of blanks to FORMATTED-LINE"
> >     SPACE-COUNT integer!
> > ] [
> >         PRINT ["NOW WE WILL ADD " SPACE-COUNT " SPACES"]
> >     loop SPACE-COUNT [
> >         append FORMATTED-LINE " "                          ;; 4444
> >             PRINT ["FORMATTED LINE IS " LENGTH? FORMATTED-LINE "
> > BYTES:" FORMATTED-LINE]
> >     ]
> > ]
> >
> > TEST-PROCEDURE
> > PRINT DATA-FORMATTED
> >
> >
> >
> > --
> > To unsubscribe from this list, just send an email to
> > [EMAIL PROTECTED] with unsubscribe as the subject.
> >
> --
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.
>
-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to