Tips & Trix
Find Your CD: Scan All Possible CD ROM Drives

Home
PUBz
Grafx Pax
Tips & Trix
Neo-Linx
Neo-Talk
Neo-Filez
Search NeoDezign
 
 

 

John Ballard came up with a great solution for our need to find our CD in whatever CDROM drive it might be in. I have seen new computers with CD's installed as high as Q: drive, for some odd reason! And, with DVD's and Writers becoming more and more affordable some people may have more than one CD ROM drive in their system. If an end-user has two CD ROM drives the NeoBook [CDRomDrive] global variable becomes inaffective as it will only return the drive letter of the first CD ROM drive.

John's script scanned each and every possible drive letter looking for the existence of a specified file. If that file did not exist in the expected location the script would continue to the next subsequent drive letter until the file was found or drive Z: was scanned.

While John's script was very thorough, he admits it can also get somewhat lengthy if you want to scan all the way to the Z: drive. I tinkered with John's original concept and came up a another shorter routine for the same problem. 

Together, John and I came up with the script shown below.
 

.build a string with all the drive letters D through Z
SetVar "[string]" "defghijklmnopqrstuvwxyz"

.determine the length of the drive string
StrLen "[string]" "[string_len]"

SetVar "[x]" "1"
.loop until x = the length of the drive string
While "[x]" "<=" "[string_len]"

.pick out one drive letter at a time
SubStr "[string]" "[x]" "1" "[drive]"

.check for the file at this drive letter
FileExists "[drive]:\MyFile.EXT" "[FileEx]"

If "[FileEx]" "=" "TRUE"
.here we've found the file so store the 
.drive letter in the var [cd]
SetVar "[cd]" "[drive]:\"

AlertBox "File was Found" "OK to continue with program"
GotoLine "TheEND"
Else
Math "[x]+1" "" "[x]"
EndIf

EndWhile

."let's give the user a chance to make sure the CD
.drive isn't just really really slow and the script
.executed too fast or some such nonesense"

MessageBox "File Not Found" "The Correct CD could not be found. |Perhaps the CD-ROM drive was idle.|What would you like to do?" "Try Again|Cancel" "[TryAgain]"

If "[TryAgain]" "=" "1"
gotoline "1"
EndIF

If "[TryAgain]" "=" "2"
."If the user cancels, you could put an exit command 
.so that your program cannot be run without the 
.correct CD. Or you could give them a note that says
.the program will not open all files until the correct CD 
.is located...just some ideas. Have fun."
Exit "" ""
EndIf
 

:TheEND


Here is a Copy & Paste friendly version of the script shown above. This file is actually a NeoBook Button Object. It looks like a bunch of gobbley-gook but all you need to do is Copy it to the clipboard then Paste it into your NeoBook project. 

After you click the link below press Ctrl+A to Select All. Then press Ctrl+C to Copy. Move to your NeoBook project and press Ctrl+V to Paste. Bam! There's your button...

findcd.txt