<READLN>-- how to "skip" the last line retrieved

Post Reply
Mr. Bigglesworth
Posts: 56
Joined: Fri Feb 16, 2001 6:54 pm

<READLN>-- how to "skip" the last line retrieved

Post by Mr. Bigglesworth »

If I've got a file that looks like so:

<!--my file-->
hello
there
my
name
is
Mr.
Bigglesworth
<!--end my file-->

Where the first and last lines server as delimiters of sorts.

I can skip the first line, of course, with a skip=1 in the READLN command. Is there a way to also skip the *last* line, from the command, as well? Maybe some sort of comparison between $loop and $next?
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

<READLN>-- how to "skip" the last line retrieved

Post by Kai »

You'd have to <rex> for that end tag and skip the line if it contains it:

<readln skip=1 row $myfile>
<$line = $ret>
<rex "<\!--=\space*end my file=" $line>
<if $ret eq "">
... process $line ...
</if>
</readln>

Or implement a one-line buffer and work on the previous line each iteration:

<readln skip=1 row $myfile>
<$line = $ret>
<if $loop gt 0>
... process $prev ...
</if>
<$prev = $line>
</readln>
Post Reply