home *** CD-ROM | disk | FTP | other *** search
- '*** GetDir.Bas - returns the current directory for a specified drive
-
- CLS
- LINE INPUT "Which drive? ", D$
- CALL GetDir(D$, Directory$)
- PRINT "The current directory on drive " D$ " is \" Directory$
- END
-
-
- SUB GetDir(Drive$, Dir$) STATIC
-
- LOCAL Drive, Descriptor!, Address!
-
- Dir$ = SPACE$(64) 'make room for directory name
-
- IF Drive$ = "" THEN 'a drive wasn't specified, so
- Drive = 0 ' use the default drive
- ELSE
- Drive = ASC(UCASE$(Drive$)) - 64 'adjust so "A"=1, "B"=2, etc.
- END IF
-
- DEF SEG = VARSEG(Dir$) 'find Dir$ descriptor address
- Descriptor! = VARPTR(Dir$)
- Address! = PEEK(Descriptor! + 2) + 256! * PEEK(Descriptor! + 3)
-
- DEF SEG 'find string data segment at
- REG %DS, PEEK(0) + 256! * PEEK(1) 'address 0, and put it in DS
- REG %SI, Address! 'offset within segment in SI
- REG %DX, Drive 'specify drive in DL
- REG %AX, &H4700 'specify service &H47 in AH
-
- CALL INTERRUPT &H21 'call DOS
-
- IF Dir$ = SPACE$(64) THEN 'error - indicate this to the
- Dir$ = "Error" ' caller with error message
- EXIT SUB
- END IF
-
- 'keep only the name portion; DOS marks end with a CHR$(0)
- Dir$ = LEFT$(Dir$, INSTR(Dir$, CHR$(0))-1)
-
- END SUB
-
- $INCLUDE "RegNames.Inc" 'this file defines registers,
- ' and is on the Turbo disk