home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / DEFAULT.ASM < prev    next >
Assembly Source File  |  1991-08-16  |  5KB  |  120 lines

  1. ; File......: DEFAULT.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   15 Aug 1991 23:06:40  $
  4. ; Revision..: $Revision:   1.2  $
  5. ; Log file..: $Logfile:   E:/nanfor/src/default.asv  $
  6. ; This is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   E:/nanfor/src/default.asv  $
  13. ;  
  14. ;     Rev 1.2   15 Aug 1991 23:06:40   GLENN
  15. ;  Forest Belt proofread/edited/cleaned up doc
  16. ;  
  17. ;     Rev 1.1   14 Jun 1991 19:54:22   GLENN
  18. ;  Minor edit to file header
  19. ;  
  20. ;     Rev 1.0   01 Apr 1991 01:03:12   GLENN
  21. ;  Nanforum Toolkit
  22. ;  
  23. ;
  24.  
  25.  
  26. ;  $DOC$
  27. ;  $FUNCNAME$
  28. ;     FT_DEFAULT()
  29. ;  $CATEGORY$
  30. ;     DOS/BIOS
  31. ;  $ONELINER$
  32. ;     Retrieve and optionally change the current default drive
  33. ;  $SYNTAX$
  34. ;     FT_DEFAULT( [ <cDrive> ] ) -> cDrive
  35. ;  $ARGUMENTS$
  36. ;     <cDrive> is optional, and if specified is the new default drive.
  37. ;  $RETURNS$
  38. ;     The current default drive.  If a change of default drive is requested,
  39. ;     the return value is the drive AFTER the change is made.  This allows
  40. ;     you to make sure you specified a valid drive (i.e. if you attempt to
  41. ;     change the default drive, and the function returns a different drive
  42. ;     letter than the one you specified, then the drive does not exist).
  43. ;  $DESCRIPTION$
  44. ;     Useful any time you need to know or change the default drive.
  45. ;
  46. ;     The source code is written to adhere to Turbo Assembler's IDEAL mode.
  47. ;     To use another assembler, you will need to rearrange the PROC and
  48. ;     SEGMENT directives, and also the ENDP and ENDS directives (a very
  49. ;     minor task).
  50. ;  $EXAMPLES$
  51. ;     cDrive := FT_DEFAULT()  && Get the current drive
  52. ;     FT_DEFAULT("C")         && Switch to drive C
  53. ;
  54. ;     IF FT_DEFAULT("E") != "E"
  55. ;        Qout( "Drive E does not exist!" )
  56. ;     ENDIF
  57. ;  $END$
  58. ;
  59.  
  60.          IDEAL
  61.  
  62. Public   FT_DEFAULT
  63.  
  64. Extrn    __ParInfo:Far
  65. Extrn    __ParC:Far
  66. Extrn    __RetC:Far
  67.  
  68. Drive    EQU       Word Ptr BP - 2
  69.  
  70. Segment  _NanFor   Word      Public    "CODE"
  71.          Assume    CS:_NanFor
  72.  
  73. Proc     FT_DEFAULT          Far
  74.  
  75.          Push      BP                        ; Save BP
  76.          Mov       BP,SP                     ; Set up stack reference
  77.          Sub       SP,2                      ; Allocate space for drive
  78.  
  79.          Xor       AX,AX                     ; Prepare to count params
  80.          Push      AX                        ; Save on stack
  81.          Call      __ParInfo                 ; Retrieve param count
  82.          Or        AX,AX                     ; Zero parameters passed?
  83.          JZ        GetDrive                  ; If so, don't set drive
  84.  
  85.          Mov       AX,1                      ; Specify first parameter
  86.          Push      AX                        ; Save parameter # on stack
  87.          Call      __ParInfo                 ; Get param type
  88.          Test      AX,1                      ; Parameter a character?
  89.          JZ        GetDrive                  ; If not, don't set drive
  90.  
  91.          Mov       AX,1                      ; Select parameter #1
  92.          Push      AX                        ; Save parameter # on stack
  93.          Call      __ParC                    ; Retrieve it
  94.          Mov       ES,DX                     ; Load segment value
  95.          Mov       BX,AX                     ; Load offset value
  96.          Mov       DL,[Byte Ptr ES:BX]       ; Get drive letter
  97.          And       DL,0DFh                   ; Convert to uppercase
  98.          Sub       DL,"A"                    ; ASCII to binary
  99.          Mov       AH,0Eh                    ; DOS service--set default drive
  100.          Int       21h                       ; Call DOS
  101.  
  102. GetDrive:Mov       AH,19h                    ; DOS service--get current drive
  103.          Int       21h                       ; Call DOS
  104.          Add       AL,"A"                    ; Binary to ASCII
  105.          CBW                                 ; Zero terminate string
  106.          Mov       [Drive],AX                ; Store default drive
  107.  
  108. Finish:  Push       SS                       ; Save segment on stack
  109.          LEA        AX,[BP - 2]              ; Move offset to AX
  110.          Push       AX                       ; Save offset on stack
  111.          Call      __RetC                    ; Send return value to Clipper app
  112.          Mov       SP,BP                     ; Restore SP
  113.          Pop       BP                        ; Restore BP
  114.          Ret
  115. Endp     FT_DEFAULT
  116. Ends     _NanFor
  117. End
  118.  
  119.