Microsoft KB Archive/62202

= WHEREIS.BAS Problem Under MS-DOS 4.x and 5.0 =

Article ID: 62202

Article Last Modified on 11/21/2006



This article was previously published under Q62202



SUMMARY
The sample program WHEREIS.BAS searches for the location of a specific file on disk. WHEREIS uses the Basic SHELL statement to perform a DOS DIR command and redirects the results to a file that WHEREIS.BAS later scans for the file it is searching for.

Under MS-DOS versions 4.0, 4.01, an 5.0, the WHEREIS.BAS program SHELL command does not function correctly. The path specification string passed to the DOS DIR command from WHEREIS ends with a backslash character, resulting in a DIR command something like the following: DIR C:\QB45\x\ This form of the DIR command returns a list of files in the QB45 directory when used under MS-DOS 3.x and earlier. Under MS-DOS 4.0, 4.01, and 5.0, this command fails with the error message &quot;Invalid directory.&quot; Removing the trailing backslash allows the DIR command to operate under MS-DOS 4.x and 5.0.

This information applies to the WHEREIS.BAS program shipped with the following products: Microsoft QuickBasic versions 4.0, 4.0b, 4.5 for MS-DOS; Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS; and Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS.



MORE INFORMATION
To correct WHEREIS.BAS to operate under MS-DOS 4.0, 4.01, and 5.0, you need to add several lines to the ScanDir SUBprogram in WHEREIS.BAS.

In the original version of WHEREIS.BAS, line 12 of the ScanDir SUB reads as follows: SHELL &quot;DIR &quot; + PathSpec$ + &quot; > &quot; + TempSpec$ To remove the trailing backslash from the string PathSpec$, replace the line above with the following: StripPath$ = PathSpec$ IF RIGHT$(StripPath$,1) = &quot;\&quot; AND LEN(StripPath$) > 1 THEN StripPath$ = LEFT$(StripPath$, LEN(StripPath$) - 1) END IF  SHELL &quot;DIR &quot; + StripPath$ + &quot; > &quot; + TempSpec$

Additional query words: QuickBas BasicCom 4.00 4.00b 4.50 5.00 6.00 6.00b 7.00 7.10

Keywords: KB62202

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.