Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Returning true when parsing a blank line

 [1/5] from: al:bri:xtra at: 6-Feb-2001 18:02


doug wrote:
> After I have read in a file line by line, how do I check for blank lines?
Try: foreach Line read/lines %File.txt [ if empty? Line [ print "Found an empty line!" ] ] Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [2/5] from: hudgeon:zipworld:au at: 6-Feb-2001 15:11


After I have read in a file line by line, how do I check for blank lines? eg x: read/lines %file.txt foreach line x [ parse line [?????] ] -- Best regards, doug mailto:[hudgeon--zipworld--com--au]

 [3/5] from: arolls:bigpond:au at: 6-Feb-2001 16:17


This prints true/false at the beginning of each line, indicating whether this line had nothing (none) in it. x: read/lines %file.txt foreach line x [print [parse line [none] line]] Do you want to combine other parse rules with the 'none possibility? Otherwise you can test using [empty? line] or [line = ""]

 [4/5] from: rebol:techscribe at: 8-Feb-2001 21:59


Hi Doug, if your intention should be to remove blank lines, then the following should work quite well: replace/all x "^/^/" "^/" Note that I am assuming that by "blank lines" you mean lines that only contain an eol character, and not lines that contain blanks, or other whitespace characters. Replace is a mezzanine function, you can see the source for replace by entering source replace at the REBOL prompt. You can adept the function to your needs. Hope this also helps, Elan doug hudgeon wrote:

 [5/5] from: hudgeon:zip:au at: 9-Feb-2001 17:07


Thanks for your reply, and your confidence that I'll be able to "adept" the function. Normally, at best, I manage to "novice" the functions. :) At 09:59 PM 08-02-01 -0800, you wrote: