Re: find if any memers of a set are in another set (blank line finder)?
I haven't tested this yet against text read in from a file, but it seems
like it *might* work, does anyone have any thing better/faster? When I put
a tab in sequence "a" below, it didn't like that, but I think a tab in a
file might be different?
Dan Moyer
<code begins>
sequence a, b
a = " "
b = "this is a line of text!"
function IsBlankLine(sequence aLine)
sequence w,x
w = aLine
x = w
w = w > 32 -- catches any characters *less* than 33
x = w < 126 -- catches any characters more than 126
w = w and x
if find(1,w) then
return 0 -- no, is *not* blank line
else
return 1 -- yes, is blank line
end if
end function
if IsBlankLine(a) = 1 then
puts(1, "yes, \"" & a & "\" is a blank line")
else
puts(1, "no, \"" & a & "\" is not a blank line")
end if
puts(1, "\n")
if IsBlankLine(b) = 1 then
puts(1, "yes, \"" & b & "\" is a blank line")
else
puts(1, "no, \"" & b & "\" is not a blank line")
end if
<code ends>
----- Original Message -----
From: "Dan Moyer" <DANIELMOYER at prodigy.net>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, July 18, 2002 5:19 AM
Subject: find if any memers of a set are in another set (blank line finder)?
>
> I want to be able to discern whether a sequence (a line of text) is
"empty"
> (ie, has *only* spaces or tabs or CR or any combination of those), or if
it
> has *any* alpha/num/punctuation content at all. In other words,a "blank"
> line finder. And it needs to function as quickly as possible.
>
> I thought there might be a spiffy way similar to how:
>
> w = {1, 2, 3} = {1, 2, 4} gives: w={1,1,0}
>
> and then I could make a sequence of the numbers 33-126 (for all the
> al/num/punc), and test any line against that sequence with an "or" in
place
> of the "="; but as a test,
>
> w = {1, 2, 3} or {1, 2, 4} gives me: w= {1,1,1}, which I don't
understand.
> (I'm thinking it means that neither 3 nor 4 are zero.)
>
> So, is there some way to find if any member of a given set is found in
> another set, or some different, good (fast) way to find "blank" lines?
>
> Dan Moyer
>
>
>
>
|
Not Categorized, Please Help
|
|