Finding the drive letter of a Windows CD-ROM
This TechNote discusses how to use the FlieIO Xtra to ensure that linked media are found when they are on a separate drive from the Director movie associated with the media. For Third Party solutions to finding a drive letter, see the notes at the end of this TechNote.
Mac linking vs. Windows linking
Windows linking can be unpredictable, having different numbers of drives and varying drive letters. Therefore, media located on a separate drive from a Director movie can present linking problems unless the drive letter is known and an absolute path can be provided. This TechNote only pertains to linking methods for Director projects playing on the Windows operating system. Because a Mac CD disk drive is defined by the CD's name, that name will already be known and the drive letter will not be a concern. For example, if the CD is named "MyCD", any path to that CD with begin with the string"MyCD:".
Linking issues can be avoided by keeping a projector and all of its media on the same disk volume in one common directory. If a Director movie and its media are on the same drive use "the moviePath" property to locate linked media. For more information see Changing linked file paths (TechNote 3126) and Using the searchPath in Director (TechNote 3125) as well as referring to "the moviePath" in the Lingo dictionary. If media are located on a CD the method described in this TechNote may be useful.
Using the FileIO Xtra to find linked media
In order to properly link a Director movie to media that are located on a separate drive the drive letter where the media are located needs to be determined. Once the drive letter is determined it can then be added to the path of the media creating a complete hard coded path. The drive letter can be detected using the FIleIO Xtra.
There is a sample movie available for download which uses the code below. To download this sample movie and view the code see Locating the drive letter of the CD-R drive (TechNote 16280). It is highly recommended to read through this entire TechNote in addition to reviewing the sample movie.Knowledge of Lingo and how to use the FileIO Xtra are necessary for implementation of this method. Macromedia Technical Support does not provide assistance with this code.
The code will successively search for the text file "weirdfile.txt" by that name on the root level of each drive letter (A to Z) in the alphabet, then return the letter name of the CD-ROM volume it finds the file on.
The behavior is in two parts. The first part is a custom handler script that can be executed anywhere in your movie.The second part of the behavior is an "on checkDrive" custom handler. This "on checkDrive" handler would typically be part of a movie script. This handler begins looking at drive C because the chance of both the A and B drive being floppy drives is very high.
Note:In order to use the script below, be sure to have a uniquely named file (here called "weirdfile.txt") at the root level of your CD drive. ------------------------------------- on CheckDrive weirdfile -- "weirdfile" is a local variable, not a file name repeat with i = 67 to 90 set drive = numTochar( i ) set thisPath = string(drive &":\"& weirdfile) set myFile = new(xtra "fileio") -- Create an instance of FileIO Xtra openFile(myFile, thisPath, 1) -- attempt to open the file if status(myfile) = 0 then -- status returns 0 for success set myFile = 0 -- Dispose of the instance return drive&":" exit end if end repeat set myFile = 0 -- Dispose of the instance alert "Please check that the file named '"& weirdfile &"' is on your CD drive." end -------------------------------------
The following example shows how to call the "on checkDrive" handler (above) from the message window. A string is returned containing the drive letter followed by a colon, for example: "E:". The drive letter can then be concatenated to the beginning of a pathname or searchpath which points to a movie's external media.
----------------------------------------- put CheckDrive("weirdfile.txt") into myCD -----------------------------------------
The following example shows how to call the "on checkDrive" handler from an "on startMovie" handler in a movie script. First, the result of "CheckDrive" is put into the variable "myCD". Then the searchPath is appended, adding myCD to the path "\quicktime". Once this handler is executed, the projector will look for linked media in the directory called "quicktime" on the root of the CD drive.
------------------------------------- on startMovie -- Note: use your actual, unique filename instead of "weirdfil.txt" put CheckDrive("weirdfil.txt") into myCD append the searchPath, myCD &"\quicktime" end -------------------------------------
Note: The searchPaths must be changed in a movie that does not contain the linked media which needs to be located. For more information seeChanging linked file paths ( TechNote 3126).
Related TechNotes and Information
Using the FileIO Xtra:
The ReadMe for the Director 5.01 FileIO Xtra (TechNote 3177)
FileIO Xtra script examples (TechNote 3192)
Using Linked Media:
Authoring tips on how to effectively use linked media (TechNote 14070)
Changing linked file paths (TechNote 3126)
Using the searchPath in Director(TechNote 3125)
Playing a Windows projector from a hard disk, but with content on CD (TechNote 3109).
Third party Xtras that can be used to determine the CD drive letter:
As an alternative to using Lingo and the FileIO Xtra to determine the CD drive letter, there are 3rd party Xtras that can be used. Examples include the free FileXtra Xtra from FileXtra3, the MasterApp Xtra sold by UpdateStage, andBuddyAPI sold by Magic Modules.
In addition, there are 3rd party installer utilities that can determine the CD-ROM drive letter, and write this information to a file (to be accessed later via FileIO) for use in your movie. For more information on 3rd party Xtras and other products, see the above links, as well as Macromedia's list of 3rd party Xtras andUpdateStage.com.Macromedia does not provide technical support for 3rd party products.
See the Director online forums (TechNote 3100) for advice from other Director developers and professionals.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
