home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / qb_lib / getpath.asm < prev    next >
Encoding:
Assembly Source File  |  1990-07-07  |  2.0 KB  |  70 lines

  1. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. ;
  3. ;    Name :     GetPath.ASM - This is a QB4 SUB which places the fully
  4. ;        qualified DOS pathname for the current default drive and path
  5. ;        into a STRING variable which you define within QB.
  6. ;
  7. ;    Revised :  07/07/90 08:49am
  8. ;
  9. ;      Notes :     - The single parameter passed to this SUB is a STRING
  10. ;        which has ALREADY BEEN DEFINED within QB4.
  11. ;        - The definition is a STRING of 67 blank spaces.
  12. ;        - When finished, the passed STRING will contain the drive
  13. ;               spec followed by ":\" and the rest of the DOS path.
  14. ;               - The STRING will be padded as needed with blank spaces
  15. ;               (i.e., CHR$(32) characters) so that you can use RTRIM$.
  16. ;        - The rightmost character will NOT be a "\", so add that
  17. ;               within your CALLing program if you need it.
  18.  
  19. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  20.  
  21.     .MODEL    MEDIUM,BASIC
  22.     .CODE
  23.  
  24. GetPath         PROC USES SI,TEXTHOLDER:WORD
  25.  
  26.     mov    BX,TEXTHOLDER
  27.     mov    SI,[BX+2]         ; SI = start of passed STRING
  28.     mov    CX,[BX]            ; CX = the LEN of passed STRING parm
  29.     cmp    CX,67            ; The passed STRING MUST be long enough!!
  30.         jb      LeaveGetPath
  31.  
  32.     mov    AH,19h
  33.     int    21h            ; This results in the current drive
  34.                     ;    spec being returned in AL
  35.     mov    DL,AL
  36.     inc    DL            ; Store the drive spec for later INT
  37.  
  38.     add    AL,65            ; Convert drive spec to ASCII character
  39.     mov    [SI],AL
  40.     inc    SI
  41.         mov     byte ptr[SI],':'        ; Add in the colon
  42.     inc    SI
  43.         mov     byte ptr[SI],'\'        ; Add in the backslash
  44.     inc    SI            ; SI past the "\" character to proceed
  45.     push    SI
  46.     mov    AH,47h
  47.     int    21h
  48.     pop    SI
  49.     mov    CX,64
  50.  
  51. ClearTrailingZERO:
  52.  
  53.     cmp    byte ptr[SI],0
  54.     jne    JustDoLoop
  55.     mov    byte ptr[SI],20h
  56.     jmp    short    LeaveGetPath
  57.  
  58. JustDoLoop:
  59.  
  60.     inc    SI
  61.     loop    ClearTrailingZero
  62.  
  63. LeaveGetPath:
  64.  
  65.     ret
  66.  
  67. GetPath        ENDP
  68.         END
  69.  
  70. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++