Announcement

Collapse
No announcement yet.

Determining which letter is active?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Determining which letter is active?

    Most people have a single floppy drive, as do I. What I *do*
    have is the ability to type in "B:" at the prompt and my floppy
    drive will act as a "B:" drive. Thus, I can copy a floppy to
    another floppy by swapping diskettes.

    Within a Powerbasic program, is there a way to determine WHICH
    of the two (A or B) letters is active at that moment?

    And secondly, if there is a disk inside the drive at that
    moment?

    Lastly, is there a way to determine if a disk is inside a ZIP
    drive?

    Thank you.

    Robert

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

  • #2
    Assuming you are typing "A:" or "B:" to select the current drive:
    Code:
    CurrentDrive$=LEFT$(CURDIR$,3)
    On the other hand, if you have written something to do a "one-physical-drive-floppy-to-floppy copy" then your program is responsible for keeping track of where you are.

    There's all kinds of code around here to determine if a disk is physically inserted.. most of it is based on trying to access a file on the target drive and trapping an error.

    i.e.
    Code:
    ON ERROR RESUME NEXT
    SourceDrive$ = "A:"
    FileSpec$    = SourceDrive$ & "\*.*"
    Z$           = DIR$(FileSpec$)
    IF ERR THEN
      IF ERR = 71 THEN
        PRINT "No disk or door open on drive " & SourceDrive$
      END IF
    END IF
    MCM


    [This message has been edited by Michael Mattias (edited July 06, 2003).]
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Michael-

      That works- I asked the question unclearly. Let me try it this
      way.

      (Let me pretend the user is a super idiot.)
      If you have a single floppy drive, and you have been making
      backups using the A: to B: technique, but the user forgot which
      "current state" he left the floppy drive in. Was it "A" or "B"?

      If I check for "A:\*.*" and it is currently acting as "B" it
      will tell me to insert a disk and press return. There is my
      problem. I would rather trap that and I haven't found a way
      to do that so far.

      In other words, is it possible to see which letter the floppy
      drive is assigned to (A or B) without having to check both?

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

      Comment


      • #4
        If I check for "A:\*.*" and it is currently acting as "B" it will tell me to insert
        ???

        It may be possible to do this, but if this is your program, you should be keeping track of it and would have no need to ask.

        In fact, I see no reason to require multiple drives to do this; sure, you'd have to prompt the user to insert the source and destination disks and maybe do a check of the directory when he says "OK"; better still...
        Code:
        Prompt ONCE to insert source Disk
        Copy everything off source disk to hard drive
        Prompt ONCE to insert destination disk
        Copy from hard drive to destination
        Delete the files from hard drive.
        ???

        MCM


        [This message has been edited by Michael Mattias (edited July 06, 2003).]
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          [quote]Originally posted by Michael Mattias:
          Code:
          Delete the files from hard drive.</font>


          Don't do that if you have the hard drive real estate available!
          Two reasons:

          1. You have an automatic backup. If the floppy goes west, just
          burn another copy from the hard drive.

          2. Frequently, copying install files from floppy to hard allows
          you to run the install program from the hard drive. Makes for
          a LOT faster installation.


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


          [This message has been edited by Mel Bishop (edited July 06, 2003).]
          There are no atheists in a fox hole or the morning of a math test.
          If my flag offends you, I'll help you pack.

          Comment


          • #6
            Background: In Olden Times, a computer would, often enough, have just
            one floppy drive. To make matters more exciting, the computer may not
            have had a hard drive at all. In any event, it was frequently handy to
            be able to copy a floppy disk without having to consider whether there
            was another floppy drive available. To make this convenient, Microsoft
            invented the "phantom" floppy: if you had only one floppy drive, you
            could address it as "A:" or "B:", and the computer would cheerfully
            pretend that you had two floppy drives.

            In short, if you said "XCOPY A: B:", the computer would copy all files
            from your "real" drive "A:", to your phantom drive "B:", which would
            actually be the same drive. But, it would prompt you to change disks
            when appropriate, so you could copy from one disk to another IN THE
            SAME DRIVE without causing problems.

            Is there a way to detect whether the A: drive is currently considered
            to be A: or B: under this sort of arrangement? Yes, but. It relies on
            "undocumented" DOS tricks that may well have changed from one version
            of DOS to another. You'll have to do some digging to find them. Start
            with the Ralf Brown list (see the Links page) and good luck.

            Now that most computers are back to one floppy, plus a hard drive, the
            old A:/B: mapping trick would be pretty handy. As it happens, though,
            Windows doesn't seem to support this any more. Thank you, Microsoft.


            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment


            • #7
              Originally posted by Tom Hanlin:

              Is there a way to detect whether the A: drive is currently considered
              to be A: or B: under this sort of arrangement? Yes, but. It relies on
              "undocumented" DOS tricks that may well have changed from one version
              of DOS to another. You'll have to do some digging to find them. Start
              with the Ralf Brown list (see the Links page) and good luck.

              [/B]
              In Ralf's check out Int 21 AX = 440Eh (IOCTL GET LOGICAL DRIVE MAP).
              It should do the trick.

              Bob

              Comment


              • #8
                Michael said: It may be possible to do this, but if this
                is your program, you should be keeping track of it and would
                have no need to ask.

                Michael, I do agree wholeheartedly, but my target users are not
                good "computer literators." Every time I offer to help, they
                remind me they are age XX been around a lot longer, etc., etc.
                Asking them which letter the floppy drive is brought me a lot
                of confusion I had to explain.

                Tom said: Now that most computers are back to one floppy,
                plus a hard drive, the old A:/B: mapping trick would be pretty
                handy. As it happens, though, Windows doesn't seem to support
                this any more. Thank you, Microsoft.


                I agree. Would you believe some of my intended users have not
                seen any version of Windows yet? This is what I do, program for
                users of DOS machines. But I have to stay mindful of that user
                who uses Windows mainly, but will run DOS programs.

                They don't want Windows apps (too big, too complicated, too
                expensive, too long to learn, etc.), and would rather have
                DOS software that is "intuitive." Because of that, that there
                was my reason for being able to determine if it was an "A" or
                "B" the floppy drive was acting as.

                Thank you all. I *think* I have come up with a non-confusing
                way to do this because of your comments. Thanks again.

                Robert

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

                Comment


                • #9
                  $IF 0
                  Robert,

                  Here is some code that you can TRY. It is a largely modified version
                  of my own production function. I have no idea if it will work in the
                  way you need. All you can do is try it. Its argument is the drive letter
                  you want to check ("a" to "z" or "A" to "Z"). It is supposed to return
                  TRUE (-1) if the drive exists, and zero in all other cases (including
                  if there are errors). All you can do is try it yourself, as I do not
                  have the hardware/software machines to test it on as far as YOUR needs.
                  $ENDIF

                  Code:
                  $COMPILE UNIT
                  $DIM ALL
                  
                  FUNCTION CheckDrive (BYVAL sDrive AS STRING) PUBLIC AS INTEGER
                      DIM IReturn AS LOCAL INTEGER
                      sDrive = UCASE$(LEFT$(sDrive, 1))
                      IF (ASCII(sDrive) < 65) OR (ASCII(sDrive) > 90) THEN
                          GOTO PEndIt
                      END IF
                      DIM w AS LOCAL ASCIIZ*7
                      DIM w2 AS LOCAL ASCIIZ*37
                      w = sDrive + ":\*.*"
                      ! push ds
                      ! push es
                      ! push si
                      ! push di
                      ! push ax
                      ! push ss
                      ! pop es
                      ! lea si, w
                      ! lea di, w2
                      ! mov ax, &H2900
                      ! int &H21
                      ! cmp al, &HFF
                      ! je P1A
                      ! mov IReturn, -1
                      P1A:
                      ! pop ax
                      ! pop di
                      ! pop si
                      ! pop es
                      ! pop ds
                      PEndIt:
                      FUNCTION = IReturn
                  END FUNCTION

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

                  Comment


                  • #10
                    <Copy from Clay>
                    Here is some code that you can TRY. It is a largely modified
                    version of my own production function. I have no idea if it
                    will work in the way you need.
                    <End>

                    Clay-

                    I will try it. From looking at it- I would say it WILL work,
                    but I should try it before actually saying it will work on the
                    intended machines.

                    Thank you, Clay.

                    Robert

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

                    Comment

                    Working...
                    X