Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Posts
    13

    Grin Can two nil values be compared from a table?

    Hi all,

    was on the forum last night finding out why my Eject if no
    cd in drive functions would not work. My new problem is
    that if there is a Cd in one of the drive then don't eject the other
    one.

    The only trouble is that Drive.GetInformation will return a nil value
    when looking at an emtpy CD-Rom Drive, but thats fine!

    How would i go about comparing to see if both drives == nil!

    Here the code:



    tDrives = Drive.Enumerate();
    for index in tDrives do
    nDriveType = Drive.GetType(tDrives[index]);

    if nDriveType == 5 then

    tDriveInformation = Drive.GetInformation(tDrives[index]);

    if tDriveInformation == nil and nil then -- it works with one (nil) but ejects
    -- The other drive, i need them to
    -- be both empty before ejecting!

    Drive.Eject(tDrives[index]);


    else

    Dialog.Message("Disc in Drive", "A disc in 1 of the Drives", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);



    end
    end
    end



    i thought the : nil and nil - would be good comparison, but it dosen't work.

    As always, Thanks in advanced for looking!

    mdxafx.

  2. #2
    Join Date
    Dec 2003
    Posts
    891
    I don't know how to get it using the AMS Drive actions (I'll have to look at it).
    But, using Worms Drive Serial dll, this will eject any drive NOT having a disc in it. Just put the dll in the path shown in the code.
    Code:
    --- get the drives on the system
    	tblDrives = Drive.Enumerate();
    	--- walk the table to process each drive
    	for n, DriveLetter in tblDrives do
    	---Get the drive type
    	nType = Drive.GetType(DriveLetter)
    	--- if the type equals 5 (Fixed), get it's Label, and Serial
    		if nType == String.ToNumber(5) then
    		sSerial = DLL.CallFunction("AutoPlay\\Docs\\dll\\DriverSer.dll", "DriveSerialNumber", "\""..DriveLetter.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL)
    		sEject = ""..DriveLetter..""..sSerial..""
    		sFound = String.Find(sEject, "ERROR", 1, true);
    			if sFound ~= -1 then
    			Drive.Eject(sEject);
    			end
    		end
    	end
    Attached Files

  3. #3
    Join Date
    Nov 2006
    Posts
    13
    Thats what my code does anyway, eject the drive which has
    no disk in it.

    what: Get.DriveInformation does is return a NIL value if there is
    no disc in the drive.

    what im trying to is see if both drive == NIL before ejecting them!
    If only one drive == Nil there is a disc in one of the drive, therefore
    do not eject any drive!

    Thanks for the reply!

    Hope someone can help me get the problem solved!

  4. #4
    Join Date
    Mar 2005
    Posts
    187
    Hi mdxafx,

    This is what I'd do in this situation. Let me know how this works out for you.

    Code:
    nFullDrive = 0; --Start out by declaring all CDROMS are empty
    tDrives = Drive.Enumerate();
    for index in tDrives do
         nDriveType = Drive.GetType(tDrives[index]);
         if nDriveType == 5 then
              tDriveInformation = Drive.GetInformation(tDrives[index]);
              if tDriveInformation ~= nil --Here look for a drive that has a disc in it
                   nFullDrives = nFullDrive+1;
              end
         end
    end
    if nFullDrive == 0 then
         Drive.Eject(tDrives[index]);
    else
         Dialog.Message("Disc in Drive", "A disc in 1 of the Drives", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    I haven't tested the code, but the idea should work. It's late and I tend to make a lot of coding mistakes late at night. =)

  5. #5
    Join Date
    May 2005
    Posts
    1,115
    Just for the hint, nil is not equal to another nil.
    Never know what life is gonna throw at you.
    (Based on a true story.)

  6. #6
    Join Date
    Nov 2006
    Posts
    13
    Buffman: i corrected the errors and typo's in your code :



    nFullDrive = 0; --Start out by declaring all CDROMS are empty
    tDrives = Drive.Enumerate();
    for index in tDrives do
    nDriveType = Drive.GetType(tDrives[index]);
    if nDriveType == 5 then
    tDriveInformation = Drive.GetInformation(tDrives[index]);
    if tDriveInformation ~= nil then -- (then) was missing!
    nFullDrive = nFullDrive+1; -- was: nFullDrives = nFullDrive+1;
    end
    end
    end
    if nFullDrive == 0 then
    Drive.Eject(tDrives[index]);
    else
    Dialog.Message("Disc in Drive", "A disc in 1 of the Drives", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end


    Correct me: -

    but this code does not work because the three end statements closes
    the argument therefore the : Drive.Eject(tDrives[index]);
    returns: can't find string!

    If you put:

    if nFullDrive == 0 then
    Drive.Eject(tDrives[index]);
    else
    Dialog.Message("Disc in Drive", "A disc in 1 of the Drives", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end

    before the three end statements you get
    1 drive opens
    1 stays closed (if you have 2 drive, 1 with a disc in it!).

    Im going to look at this in more depth!

    Any suggestion in the mean while of how this could be done would
    be helpful!

    Thanks to all!

Similar Threads

  1. problem closing a running process..
    By Lucian Cain in forum AutoPlay Media Studio 5.0
    Replies: 5
    Last Post: 08-22-2006, 04:17 PM
  2. What's wrong?
    By playmenow in forum AutoPlay Media Studio 6.0
    Replies: 11
    Last Post: 03-04-2006, 07:10 AM
  3. Compare Values in tables
    By Byte in forum AutoPlay Media Studio 5.0
    Replies: 7
    Last Post: 06-18-2005, 02:36 PM
  4. Table Double-Click is nil
    By GalacTek in forum AutoPlay Media Studio 5.0
    Replies: 7
    Last Post: 09-22-2004, 06:28 PM
  5. Replies: 4
    Last Post: 12-06-2003, 01:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts