Indigo Rose Software

Professional Software Development Tools

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

    Need help on solving Drive Action problem!

    Read so much on the Drive. Functions that its making me ill.

    What im trying to is simple but my error codes i can't figure out.

    All it is:
    1. Get a list of Drive on the computer
    2. Get the type of Drives from the List of Drives, e.g( 5 == CD-ROM)
    3. Check the type to see if Drive == 5 (CD-ROM)
    4. If they are Type 5 then get the Display Name from the drive
    5. If the Display name =="" no string Label then
    6. Eject each of the Drive/s!

    In over word check to see if each drive(CD-Rom) has a Disc
    in it!

    Here the code i've been working on:-

    -----------------------------------------------------------------------

    --Generate Drive List
    GenerateDrivesL = Drive.Enumerate();


    --Index Drive List
    for i, DrivesList in GenerateDrivesL do

    --Check Drive Type from list
    WhichDrive = Drive.GetType(DrivesList);

    -- See if drive type == 5 (CD-ROM Drives)
    if WhichDrive == 5 then

    --Check CD-ROM Drive Display name
    Output = Drive.GetInformation(DrivesList).DisplayName;

    --If the string is blank eject the drives!!
    if Output == "" then

    Drive.Eject(CDDVD);

    end

    end


    -------------------------------------------------------------
    my error displays:

    Output = Drive.GetInformation(DrivesList).DisplayName;

    is attempting to Index a Nil value!

    Thanks in advance for looking at the code!
    mdxafx

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    right, its because Drive.GetInformation returns a error when there is no disk in the drive, so you have to use the error to trigger the event


    tDrives = Drive.Enumerate();
    for index in tDrives do
    nDriveType = Drive.GetType(tDrives[index]);
    if nDriveType == 5 then
    tDriveInformation = Drive.GetInformation(tDrives[index])
    error = Application.GetLastError();
    if (error ~= 0) then
    Drive.Eject(tDrives[index]);
    else
    result = Dialog.Message("Notice", "there is a disk in the drive", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    end
    end
    hope it helps
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Nov 2006
    Posts
    13
    Surely if im using an (if) statement to test to see if the varible (Output) contains any string ("") should work for each drive!


    there should be no error until the (if) statement is called!
    I thought?

  4. #4
    Join Date
    May 2006
    Posts
    5,380
    yeah, but the fact that you are useing "if" means that it is calling the event to check the condition and the if statment returns a error or nil if is there is no information to return

    in this case, if there is no disk in the drive "Drive.GetInformation" will return a error because there is no information to return, so you use the error the check the condition

    try my code
    Open your eyes to Narcissism, Don't let her destroy your life!!

  5. #5
    Join Date
    Nov 2006
    Posts
    13
    Thanks RizlaUK

    i see, Drive.GetInformation send an error because there
    is no information to be given from those drives!

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    np problem, it took me a while to get my head round
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Nov 2006
    Posts
    13

    Smile

    Hi RizlaUK,

    i was doing some tests earlier and found that the following also
    works, without using GetLastError. It basically just see if
    Drive.GetInformation() has a value in it!


    tDrives = Drive.Enumerate();
    for index in tDrives do
    nDriveType = Drive.GetType(tDrives[index]);
    if nDriveType == 5 then
    tDriveInformation = Drive.GetInformation(tDrives[index]);
    --error = Application.GetLastError();
    --if (error ~= 0) then
    if tDriveInformation == nil then
    Drive.Eject(tDrives[index]);

    else

    Dialog.Message("Notice", "there is a disk in the drive", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    end
    end
    end


    Thanks for all your help!

  8. #8
    Join Date
    May 2006
    Posts
    5,380
    yeah, like i said, it returns a error or nil, i just had problems getting the "nil" bit to work for me, guess i formatted it wrong

    cheers for the heads up
    Open your eyes to Narcissism, Don't let her destroy your life!!

Similar Threads

  1. what action do yo use to find the installsource?
    By tricky1979 in forum AutoPlay Media Studio 5.0
    Replies: 7
    Last Post: 07-22-2006, 01:35 PM
  2. New (?) problem with File.Open action
    By yosik in forum AutoPlay Media Studio 5.0
    Replies: 3
    Last Post: 03-23-2005, 09:29 AM
  3. Problem with internet download web file action! Please help!
    By Martin_SBT in forum AutoPlay Media Studio 4.0
    Replies: 1
    Last Post: 05-27-2003, 02:48 PM
  4. INFO: Tips for Debugging Action Lists in AutoPlay Media Studio 4.0
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-03-2002, 08:38 AM
  5. SUF6.0.0.2 -- installer hangs.
    By jassing in forum Setup Factory 6.0
    Replies: 4
    Last Post: 12-19-2001, 11:28 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