Change Current DOS Directory

From CometWiki

Jump to: navigation, search

Change Current DOS Directory (CHDIR) Syntax:

 DOSFC(AX-value, CX-value, subdirectory-name) EXCP=statement-label  

Entry:

 AX-value = "@3B00@"
 CX-value = "@0000@"

Return:
If an exception occurs, byte 2 of the AX field will contain the DOS error code (in hex).


Discussion:
The DOSFC function call can be used to change the current DOS directory. This function requires that the AX-value be set to "@3B00@", the CX-value be set to null, and the subdirectory-name contain the name of the new DOS subdirectory.
After the DOSFC function is executed, the current directory will be changed to the directory name supplied in the call.

Example:

 ! S SCHDIR,DSK
 ! O CHDIR,DSK
 ! L T00,E
 ! R QMONITOR
 !
 !==========  CHANGE CURRENT DOS DIRECTORY =======================
 !
 LENGTH 2 & LOCAL AX$,BX$,CX$,DX$        ! Define registers
 LENGTH 64 & LOCAL DIRECTORY$            ! Define directory name
 !
 LENGTH 3 & LOCAL DOSCODE$               ! Define DOS error code
 LENGTH 37 & LOCAL DOSMESSAGE$           ! Define DOS message
 !
 1000 FORMAT DOSMESSAGE$                 ! File input format
 !
 100 FORMAT (ET)                         ! Screen format
 !
 CLEAR                                   ! Initialize variables
 PRINT (0,100)                           ! Set typewriter mode
 !
 PRINT (0) "ENTER DIRECTORY NAME:"       ! Display prompt
 INPUT (0) DIRECTORY$                    ! Enter directory name
 IF DIRECTORY$ = "" THEN RUN "QMONITOR"  ! If null, then stop
 !
 AX$ = "@3B00@"                          ! Set AX to "Chg. dir."
 CX$ = "@0000@"                          ! Set CX register to null
 !
 DOSFC(AX$,CX$,DIRECTORY$) EXCP=EXCEPTION  ! Perform DOSFC call
 !
 PRINT (0) "CHANGED TO SUBDIRECTORY ";DIRECTORY$
 INPUT (0) ""
 RUN "QMONITOR"
 !
 EXCEPTION:                              ! Exception routine
 PRINT (0) "DIRECTORY NOT CHANGED."      ! Display message
 OPEN (1) "QERCOMET"                     ! Open error file
 DOSCODE$ = "D" + HEXASC(SUB(AX$,2,1))   ! Construct key to file
 READ (1,1000) KEY=DOSCODE$              ! Read error record
 PRINT (0) "DOS error code: ";DOSCODE$   ! Display DOS error code
 PRINT (0) DOSMESSAGE$                   ! Display error message
 INPUT (0) ""                            ! Hold
 CLOSE (1)                               ! Close error file
 RUN "QMONITOR"                          ! Exit
 END
Personal tools