Subject: | |
From: | |
Reply To: | |
Date: | Thu, 3 Sep 1998 09:48:56 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Steve Bagdon wrote:
>
> Anyone have a quick example on how to read through an ascii file,
> waiting for eof, and reading each record into a UDC variable for
> processing?
Others have mentioned the use of a message file. Another way to do this
is to pipe the file you want to read as input to your command. Here are a
couple of examples of how you might do this.
Mike.
1. When the file already exists
:say < rhyme
Mary had a little lamb
its fleece was white as snow
and everywhere that Mary went
the lamb was sure to go
:help say
User-defined command:
setvar n finfo(hpstdin,"eof")
while setvar(n,n-1) >=0
setvar buf input()
echo !buf
endwhile
2. When you want to create the file and process the contents
:whereis operator
#J1760 EXEC 10S LP SAT 1:49P STATXXXJ,OPERATOR.SYS
#S1265 EXEC 2003 2003 WED 10:26A RONALD,OPERATOR.SYS
#S1396 EXEC 1124 1124 THU 4:12A SAHID,OPERATOR.SYS
#S1406 EXEC 79 79 THU 9:18A JONER,OPERATOR.SYS
:help whereis
User-defined command:
anyparm ARG=!hpaccount
if lft(hpstdin,2)="$S"
showjob > stdlist
whereis !ARG< stdlist
return
endif
setvar n finfo(hpstdin,"eof")
while setvar (n,n-1) > 0
if lft(setvar(buf,input()),1)='#'
if setvar (pos, pos(ups("!arg"),buf)) > 0
echo !buf
endif
endif
endwhile
|
|
|