Subject: | |
From: | |
Reply To: | |
Date: | Wed, 4 Nov 1998 10:57:47 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On Nov 4, 11:19am, John Dunlop wrote:
...
> The only valid characters are
> numbers 0-9, all upper case characters and spaces. I was going to use
...
There have been some fast responses. Here is a way to do it in the CI
that is similar to John's example, but may be a bit faster than his
original script.
Jeff Vance, CSY
----------------
# assumes stdin redirected to the file in question...
setvar eof finfo(hpstdin,'eof')
setvar line 0
while setvar(line,line+1) <= eof do
setvar buf repl(input()," ","")
if not (alphanum(buf) and ups(buf) = buf) then
# some lowercase letters or non-alphanum chars
# find 1st occurrence of non-conforming char
setvar i 0
setvar buflen len(buf)
while setvar(i,i+1) <= buflen and &
alphanum(setvar(char,str(buf,i,1))) and ups(char) = char do
endwhile
echo Line !line contains a "!char"
endif
endwhile
-------------
Differences are: a smaller body in the while loops which will be
noticeable for larger input files. Also, each individual character
is only scanned if we know the entire line is not alphanumeric. I
tried to optimize this assuming the input file is valid.
jv
--
|
|
|