Create DOS File
From CometWiki
(Difference between revisions)
(New page: Create DOS File Syntax: DOSFC(AX-value, CX-value, file-name) EXCP=statement-label Entry: AX-value = "@3C00@" CX-value = "@0000@" Return: If the function call is successful, t...) |
|||
Line 1: | Line 1: | ||
- | Create DOS File | + | '''Create DOS File''' |
- | + | ||
- | + | ||
- | + | ||
+ | '''Syntax:'''<br>DOSFC(AX-value, CX-value, file-name) EXCP=statement-label | ||
+ | '''Entry:'''<br>AX-value = "@3C00@" | ||
+ | CX-value = "@0000@" | ||
- | Return: | + | '''Return:''' <br>If the function call is successful, the AX field will contain the |
file's handle. | file's handle. | ||
- | + | If an exception occurs, byte 2 of the AX field will contain the | |
DOS error code (in hex). | DOS error code (in hex). | ||
- | Discussion: | + | '''Discussion:'''<br> |
+ | The DOSFC function call can be used to create a DOS file. This call requires that the AX-value be set to "@3C00@", the CX-value to null, and the file-name to the name of the DOS file to be created (including disk and path name).<br> | ||
After the call is executed, the AX field will contain the file's handle. It is imperative that this value be stored for future use (i.e., for closing the file). | After the call is executed, the AX field will contain the file's handle. It is imperative that this value be stored for future use (i.e., for closing the file). | ||
- | Example: | + | '''Example:''' |
+ | ! S SFCREATE,DSK | ||
! O FCREATE,DSK | ! O FCREATE,DSK | ||
! L T00,E | ! L T00,E |
Latest revision as of 09:35, 13 June 2009
Create DOS File
Syntax:
DOSFC(AX-value, CX-value, file-name) EXCP=statement-label
Entry:
AX-value = "@3C00@"
CX-value = "@0000@"
Return:
If the function call is successful, the AX field will contain the
file's handle.
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 create a DOS file. This call requires that the AX-value be set to "@3C00@", the CX-value to null, and the file-name to the name of the DOS file to be created (including disk and path name).
After the call is executed, the AX field will contain the file's handle. It is imperative that this value be stored for future use (i.e., for closing the file).
Example:
! S SFCREATE,DSK ! O FCREATE,DSK ! L T00,E ! R QMONITOR ! !========== CREATE DOS FILE =================================== ! LENGTH 2 & LOCAL AX$,CX$ ! Define registers LENGTH 2 & LOCAL FILEHANDLE$ ! Define file handle 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:" ! Display prompt INPUT (0) FILENAME$ ! Enter file name IF FILENAME$ = "" THEN RUN "QMONITOR" ! If null, then stop FILENAME$ = FILENAME$ + "@00@" ! Add null byte to name ! AX$ = "@3C00@" ! Set AX to "CREATE FILE" CX$ = "@0000@" ! Set CX register to null ! DOSFC(AX$,CX$,FILENAME$) EXCP=EXCEPTION ! Perform DOSFC call ! FILEHANDLE$ = AX$ ! Save file handle ! PRINT (0) FILENAME$;" CREATED SUCCESSFULLY." PRINT (0) "FILE HANDLE IS:";FILEHANDLE$ INPUT (0) "" RUN "QMONITOR" ! EXCEPTION: ! Exception routine PRINT (0) "FILE NOT CREATED." ! 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