Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank Line Detection and Deletion

Status
Not open for further replies.

hankm3

Programmer
Jan 27, 2002
284
US
Hi,

I want to Delete Blank Lines in a Text File, before I Transmit the File to a Host Computer. I wrote the following Script that will Detect the Blank Lines, now just a Method to get rid of them.

Thanks

proc main
string sLine
string sTok
integer c = 0

fopen 1 "C:\TEXT FILES\BLANK_TEST.txt" READ TEXT
while not feof 1
fgets 1 sLine
strtok sTok sLine " " 1
if nullstr sTok
c++
endif
endwhile
usermsg "Total Blank Lines Found %d" c
endproc
 
Darn UnSend Button,

Well one more for the Books... This does the Trick..

;*
;* Get Blank Line Count
;* Copy Non-Blank Lines
;* to File Blank_out.txt
;*
proc main
string sLine
integer Len
integer c = 0

fopen 1 "C:\TEXT FILES\BLANK_TEST.txt" READ TEXT
fopen 2 "C:\TEXT FILES\BLANK_OUT.txt" CREATE TEXT
while not feof 1
fgets 1 sLine
strlen sLine Len
if Len == 0
c++
else
fputs 2 sLine
endif
endwhile
fclose 1
fclose 2
usermsg "Blank Lines Found %d" c
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top