Erase DOS File

From CometWiki

Jump to: navigation, search

Erase DOS File

Syntax:

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

Entry:

 AX-value = "@4100@"
 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 erase a DOS file. This function requires that the AX-value be set to "@4100@", the CX- value be set to null, and the file-name parameter be set to the name of the DOS file to be erased (including disk and path name).
After this function is executed, the file will be erased.

Example:

 ! S SFERASE,DSK
 ! O FERASE,DSK
 ! L T00,E
 ! R QMONITOR
 !
 !==========  ERASE DOS FILE =====================================
 !
 LENGTH 2 & LOCAL AX$,CX$                ! Define registers
 LENGTH 64 & LOCAL FILENAME$             ! Define file 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 FILENAME TO ERASE:"    ! Display prompt
 INPUT (0) FILENAME$                     ! Enter file name
 IF FILENAME$ = "" THEN RUN "QMONITOR"   ! If null, then stop
 FILENAME$ = FILENAME$ + "@00@"          ! Add null byte to file
 !
 AX$ = "@4100@"                          ! Set AX to "ERASE FILE"
 CX$ = "@0000@"                          ! Set CX register to null
 !
 DOSFC(AX$,CX$,FILENAME$) EXCP=EXCEPTION   ! Perform DOSFC call
 !
 PRINT (0) FILENAME$;" ERASED."
 INPUT (0) ""
 RUN "QMONITOR"
 !
 EXCEPTION:                              ! Exception routine
 PRINT (0) "FILE NOT ERASED."            ! 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