home *** CD-ROM | disk | FTP | other *** search
- dim bfr(256)
- bfrst=varptr(bfr(1))
- bfrpos=bfrst
- bfrend=0
-
- cmd$=command$
- cmd$=ltrim$(cmd$)
- cmd$=ucase$(cmd$)
- ls=len(cmd$)
- i=instr(cmd$," ")
- if ls=0 then fileerr:
- if i=0 then fileerr:
- ls=ls-i
- i=i-1
- fn$=left$(cmd$,i)
- srch$=right$(cmd$,ls)
- print "Searching for ";
- print srch$;
- print " in ";
- print fn$
-
- open "I",1,fn$
- if error>0 then fileerr:
-
- fn=1
- gosub gethandle:
-
- main:
- line$=""
- gosub getline:
- if error>0 then done:
- line$=ucase$(line$)
- i=instr(line$,srch$)
- if i>0 then
- print line$
- endif
- goto main:
-
- getline:
- if bfrpos>bfrend then
- gosub readsector:
- if error>0 then
- return
- endif
- endif
- tst=peek(bfrpos)
- if tst=13 then
- bfrpos=bfrpos+2
- return
- else
- tstchr$=chr$(tst)
- line$=line$+tstchr$
- bfrpos=bfrpos+1
- goto getline:
- endif
- return
-
- readsector:
- AX=&hex3F00
- CX=512
- DX=varptr(bfr(1))
- BX=hdl
- int86(&hex21,AX,BX,CX,DX,NA,NA,NA,NA,NA)
- bfrpos=bfrst
- bfrend=bfrst+AX
- if AX=0 then
- error=99
- endif
- return
-
- gethandle:
- if fn>3 then fileerr:
- if fn<1 then fileerr:
- x=fn*3
- x=350+x
- hdl=peek(x)
- x=x+1
- y=peek(x)
- y=y*256
- hdl=hdl+y
- return
-
- fileerr:
- print "Command/File error ! "
- print "Syntax: LS filename searchstring"
- end
-
- done:
- print "Finished!"
- end
-