Jump to content

how to eject a specific cdrom


Recommended Posts

1stly to any admins, this is the 3rd time I've tried to post this. The 1st 2x when I wanted to preview the msg or submit it, I was asked for my name and password (even though I was already logged in). After resubmitting my name and password I was taken to the v3 support group, but with no sign of my request for help. (I tried going back to the 'Post a new topic' window in my history to recover & repost the request only to find it wiped.

...Ok now onto the 3rd posting...

I'm having some problems with detecting which cdrom drive contains a specific cdrom.

Code following:

GLOBAL $OTN_CDLabel_cd1

$OTN_CDLabel_cd1 = "01-XX-XX OTN cd1"

Get_OTN_CDDrive()
EjectCd1_GetCd2()
Exit

Func Get_OTN_CDDrive()
   $ListOfDrives = DriveGetDrive ("CDROM")
   If @Error Then MsgBox (0,"Error!", "Error getting $ListOfDrives.")
   For $Count = 1 to $ListOfDrives[0]
      $DriveLabel = DriveGetLabel ($ListOfDrives[$Count])
      If $DriveLabel = $OTN_CDLabel_cd1 Then
         $OTN_CDDrive = $ListOfDrives[$Count]
         ExitLoop
      EndIf
   Next
EndFunc

Func EjectCd1_GetCd2()
   CDTray ($OTN_CDDrive, "open")
   MsgBox (0, "Swap CDs", "Please remove OTN cd1 and put in OTN cd2. Press OK to continue.")
   CDTray ($OTN_CDDrive, "close")
EndFunc

Any help with the above code would be greatly appreciated.

Link to comment
Share on other sites

Also .. $OTN_CDDrive is local to Func Get_OTN_CDDrive(), and is not available in Func EjectCd1_GetCd2() where you try and eject the CD.

You either need to declare it globally, or passit out of the Get_OTN_CDDrive() function (and into EjectCd1_GetCd2() .. as a parm)

Edited by trids
Link to comment
Share on other sites

  • Developers

think that = should work the same as == :whistle:

Agree with Trids that you need to define the $OTN_CDDrive var in the top part of the program.

CyberSlug wrote in another post:

In AutoIt, = and == have the same meaning for numbers--I think. However, the == is a case-sensitive test for strings.

"abc" = "ABC" ;evaluates to True

"abc" == "ABC" ;evaluates to False

Jos

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

hopefully this works.

EjectCd1_GetCd2(Get_OTN_CDDrive("01-XX-XX OTN cd1"))
Exit

Func Get_OTN_CDDrive($OTN_CDLabel_cd1)
  $ListOfDrives = DriveGetDrive ("CDROM")
  If @Error Then MsgBox (0,"Error!", "Error getting $ListOfDrives.")
  For $Count = 1 to $ListOfDrives[0]
     $DriveLabel = DriveGetLabel ($ListOfDrives[$Count])
     If $DriveLabel = $OTN_CDLabel_cd1 Then return $OTN_CDDrive;
  Next
EndFunc

Func EjectCd1_GetCd2()
  CDTray ($OTN_CDDrive, "open")
  MsgBox (0, "Swap CDs", "Please remove OTN cd1 and put in OTN cd2. Press OK to continue.")
  CDTray ($OTN_CDDrive, "close")
EndFunc

[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...