mIRC Home    About    Download    Register    News    Help

Print Thread
#128392 24/08/05 02:20 PM
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
hi im using $read to loop through a file but whenever a blank line comes up..the script stops. there is nothing wrong with my script (i checked by removing the blank lines), how can i stop this from happening?
I would also like to know how i can write these blank lines to the file (for the output)

thanks laugh

Joined: Aug 2005
Posts: 128
S
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
Quote:
hi im using $read to loop through a file but whenever a blank line comes up..the script stops. there is nothing wrong with my script (i checked by removing the blank lines), how can i stop this from happening?
I would also like to know how i can write these blank lines to the file (for the output)

thanks laugh


Probabilly you use something like:
Code:
var %i = 1
while ($read(file.txt,n,%i)) {
echo -a line %i : $ifmatch
inc %i
}

This will stop at first empty line, but u can use $lines to avoid this:
Code:
var %i = 1, %l = $lines(file.txt)
while (%i <= %l) {
echo -a line %i : $read(file.txt,n,%i)
inc %i
}

This also shows empty lines smile

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
awesome, it works :P
didn't think that would make a difference
thanks laugh
any idea how i can write the blankness to a differnt text file?
thanks again :P

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
write -i file2.txt

This should append a blank line at the end of file2.txt

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
cool thanks ill try tht

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
I just say make it as simple as possible and just use $fgetc to read the file. You won't miss any character.


Beware of MeStinkBAD! He knows more than he actually does!

Link Copied to Clipboard