home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / sbl / sbleval / dirdemo.sbl next >
Encoding:
Text File  |  1993-04-08  |  1.2 KB  |  45 lines

  1. '
  2. ' This example was copied directly from Visual Basic.  It has not
  3. ' been changed or altered in any way
  4. '
  5.  
  6. 'Dir$ Function Example
  7.  
  8. Sub DirDemo ()
  9.   NL$ = Chr$(13) + Chr$(10): TB$ = Chr$(9)  ' Define newline, tab.
  10.   Msg$ = "Enter a file specification."
  11.   Filespec$ = InputBox$(Msg$) ' Get filename.
  12.   Match$ = Dir$(Filespec$)  ' Find first match.
  13.   If Len(Match$) Then ' If match found.
  14.     Do
  15.       MatchNum% = MatchNum% + 1 ' Increment match count.
  16.       Msg2$ = Msg2$ + NL$ + TB$ + Match$  ' Make a list.
  17.       If Len(Msg2$) >= 180 Then ' Handle list too long
  18.         Match$ = "And more - - -" ' for MsgBox.
  19.         Msg2$ = Msg2$ + NL$ + TB$ + Match$
  20.         Exit Do ' Quit Do Loop.
  21.       End If
  22.       Match$ = Dir$ ' Find next match.
  23.  
  24.     Loop Until Len(Match$) = 0  ' Continue.
  25.     If MatchNum% > 1 Then ' More than one file.
  26.       Msg1$ = "The files that match your file specification are:"
  27.  
  28.     Else  ' One match only.
  29.  
  30.       Msg1$ = "The file that matches your file specification is:"
  31.     End If
  32.     Msg$ = Msg1$ + Msg2$  ' Put message together.
  33.   Else
  34.     Msg$ = "The file you specified could not be found."
  35.   End If
  36.  
  37.   MsgBox Msg$ ' Display message.
  38.  
  39. End Sub
  40.  
  41.  
  42. sub main
  43. call dirdemo
  44. end sub
  45.