Sign in to follow this  
Followers 0
w_sp8er

how to eject a specific cdrom

7 posts in this topic

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.

Share this post


Link to post
Share on other sites



You appear to have an assignment in the if statement when you want an equality check, i.e. it should read

If $DriveLabel == $OTN_CDLabel_cd1 Then

(note the double equals sign)

HTH


GrahamS

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

in my complete script i have declared all variable as GLOBAL

GrahamS, thank you. that fixed it right up.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

or u can have it check for a filename on the cd (maybe)


~~ Safeguarding The Land ~~

Share this post


Link to post
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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0