>
> >
> >I would do it something like this:
> >
> >file: read/lines %test.txt     ; read the file line by line
> >                               ; into a variable
> >z: length? file                ; find out how many lines there are
> >x: 0                           ; use this variable to track lines
> >loop z [                       ; set up a line by line loop
> >         x = x + 1             ; specify line number in sequence
> >          print pick file x    ; print the current line number
> >       ]
> >

Of course, you'll want to eliminate as many variables as possible,
depending on your needs.  For example:

    ;
    ; if you just need to process the lines
    ;

    foreach line read/lines %test.txt [
        print line
    ]

    ;
    ; if you need line numbers
    ;

    lines: read/lines %test.txt
    forall lines [
        print [index? lines  first lines]
    ]

and so on...

-jn-

Reply via email to