home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv2_4 / qbasic / dsearcht.bas < prev    next >
Encoding:
BASIC Source File  |  1989-03-02  |  1.2 KB  |  45 lines

  1.  
  2. rem        Figure 2
  3. rem        ========
  4.  
  5.  
  6. rem        "Test Program" for DSEARCH.
  7.  
  8.  
  9. 'dsearcht.bas
  10. 'simple program to check dsearch routine and make sure it's
  11. 'working.  The idea is to call it just enough to check out
  12. 'its capabilities, and perhaps vary its input by small
  13. 'amounts, so that you get a controlled test where there are
  14. 'no likely bugs in the BASIC code.
  15.  
  16.  
  17. rem $dynamic
  18. DIM A$(0)
  19.  
  20. start:
  21. input "Path for directory? (wildcards allowed): ",path$
  22. if instr("\:",right$(path$,1)) then path$=path$+"*.*"
  23.  
  24. 'get number of filenames in path
  25. attr%=&H10:arrofs%=0:count%=0:selective%=0
  26. call dsearch(path$,attr%,count%,selective%,arrofs%)
  27.  
  28. 'now count% has actual filename count for redim, or -1 if error
  29. '(other than file not found, that is.)
  30.  
  31. if count%=-1 then print "Bad pathname":goto start
  32. redim a$(count%)
  33.  
  34. print "There are "count%"filenames in path "path$"."
  35. 'set up a$ so that dsearch doesn't have to change length
  36. for i=0 to count%-1:a$(i)=space$(12):next i
  37.  
  38. arrptr=varptr(a$(0))
  39. arrofs%=int(arrptr)             'explicit conversion
  40.  
  41. call dsearch(path$,attr%,count%,selective%,arrofs%)
  42.  
  43. for i= 0 to count%-1:print i;":";a$(i):next i
  44. goto start
  45.