home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / asic / ls / ls.asi next >
Text File  |  1991-12-20  |  1KB  |  91 lines

  1. dim bfr(256)
  2. bfrst=varptr(bfr(1))
  3. bfrpos=bfrst
  4. bfrend=0
  5.  
  6. cmd$=command$
  7. cmd$=ltrim$(cmd$)
  8. cmd$=ucase$(cmd$)
  9. ls=len(cmd$)
  10. i=instr(cmd$," ")
  11. if ls=0 then fileerr:
  12. if i=0 then fileerr:
  13. ls=ls-i
  14. i=i-1
  15. fn$=left$(cmd$,i)
  16. srch$=right$(cmd$,ls)
  17. print "Searching for ";
  18. print srch$;
  19. print " in ";
  20. print fn$
  21.  
  22. open "I",1,fn$
  23. if error>0 then fileerr:
  24.  
  25. fn=1
  26. gosub gethandle:
  27.  
  28. main:
  29. line$=""
  30. gosub getline:
  31. if error>0 then done:
  32. line$=ucase$(line$)
  33. i=instr(line$,srch$)
  34. if i>0 then
  35.    print line$
  36. endif
  37. goto main:
  38.  
  39. getline:
  40.    if bfrpos>bfrend then
  41.       gosub readsector:
  42.       if error>0 then
  43.          return
  44.       endif
  45.    endif
  46.    tst=peek(bfrpos)
  47.    if tst=13 then
  48.       bfrpos=bfrpos+2
  49.       return
  50.    else
  51.       tstchr$=chr$(tst)
  52.       line$=line$+tstchr$
  53.       bfrpos=bfrpos+1
  54.       goto getline:
  55.    endif
  56. return
  57.  
  58. readsector:
  59.    AX=&hex3F00
  60.    CX=512
  61.    DX=varptr(bfr(1))
  62.    BX=hdl
  63.    int86(&hex21,AX,BX,CX,DX,NA,NA,NA,NA,NA)
  64.    bfrpos=bfrst
  65.    bfrend=bfrst+AX
  66.    if AX=0 then
  67.       error=99
  68.    endif
  69. return
  70.  
  71. gethandle:
  72.    if fn>3 then fileerr:
  73.    if fn<1 then fileerr:
  74.    x=fn*3
  75.    x=350+x
  76.    hdl=peek(x)
  77.    x=x+1
  78.    y=peek(x)
  79.    y=y*256
  80.    hdl=hdl+y
  81. return
  82.  
  83. fileerr:
  84. print "Command/File error ! "
  85. print "Syntax: LS filename searchstring"
  86. end
  87.  
  88. done:
  89. print "Finished!"
  90. end
  91.