<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.signature.net/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.signature.net/index.php?action=history&amp;feed=atom&amp;title=Write_to_a_DOS_File</id>
		<title>Write to a DOS File - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.signature.net/index.php?action=history&amp;feed=atom&amp;title=Write_to_a_DOS_File"/>
		<link rel="alternate" type="text/html" href="http://wiki.signature.net/index.php?title=Write_to_a_DOS_File&amp;action=history"/>
		<updated>2026-05-13T00:56:05Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>http://wiki.signature.net/index.php?title=Write_to_a_DOS_File&amp;diff=1532&amp;oldid=prev</id>
		<title>Badge: New page: '''Write to a DOS File'''  '''Syntax:'''   DOSRW(AX-value, file-handle, number-of-bytes, format-statement-label) EXCP=statement-label   '''Entry:'''    AX-value = &quot;@4000@&quot;                 ...</title>
		<link rel="alternate" type="text/html" href="http://wiki.signature.net/index.php?title=Write_to_a_DOS_File&amp;diff=1532&amp;oldid=prev"/>
				<updated>2009-06-13T10:37:19Z</updated>
		
		<summary type="html">&lt;p&gt;New page: &amp;#39;&amp;#39;&amp;#39;Write to a DOS File&amp;#39;&amp;#39;&amp;#39;  &amp;#39;&amp;#39;&amp;#39;Syntax:&amp;#39;&amp;#39;&amp;#39;   DOSRW(AX-value, file-handle, number-of-bytes, format-statement-label) EXCP=statement-label   &amp;#39;&amp;#39;&amp;#39;Entry:&amp;#39;&amp;#39;&amp;#39;    AX-value = &amp;quot;@4000@&amp;quot;                 ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Write to a DOS File'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax:'''&lt;br /&gt;
  DOSRW(AX-value, file-handle, number-of-bytes, format-statement-label) EXCP=statement-label  &lt;br /&gt;
'''Entry:''' &lt;br /&gt;
  AX-value = &amp;quot;@4000@&amp;quot;&lt;br /&gt;
                                                                                                                       .&lt;br /&gt;
  file-handle = file handle established when the file was opened&lt;br /&gt;
                                                                                                                        .&lt;br /&gt;
  number-of-bytes = number of characters to be written&lt;br /&gt;
                                                                                                                         .&lt;br /&gt;
  format-statement-label = format statement containing the data variables to be written to the DOS file&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''Return:'''  &amp;lt;br&amp;gt; &lt;br /&gt;
If the write function is successful, the data variable(s) contained in the format statement will be written to the DOS&lt;br /&gt;
file, and the AX register will contain the number of bytes tha  were actually written (in byte-reversed hex).&lt;br /&gt;
&lt;br /&gt;
If an exception occurs, byte 2 of the AX field will contain the DOS error code (in hex).&lt;br /&gt;
&lt;br /&gt;
'''Discussion:'''  &amp;lt;br&amp;gt;&lt;br /&gt;
The DOSRW function can be used to write data to a DOS file. The data to be written is listed in an Internet Basic format statement. &amp;lt;br&amp;gt;&lt;br /&gt;
This function requires that the AX-value be set to &amp;quot;@4000@&amp;quot;. The file's handle (established when the file was opened) must also be included in the function call. &lt;br /&gt;
&lt;br /&gt;
Likewise, you must specify the number of bytes to be written to the DOS file and the label of the format statement containing the data to be written to the file. &lt;br /&gt;
&lt;br /&gt;
After the function is executed, the DOS file will contain the data values from the format statement. Also, the AX register will contain the number of bytes that were actually written to the file. This value is in hex, so it will have to be converted to decimal to serve any meaningful purpose. &lt;br /&gt;
&lt;br /&gt;
One application of this AX value is to test for a &amp;quot;disk full&amp;quot; condition. For example, if the number of bytes actually written to a DOS file is less than the number specified to be written, it means that there is no more room to write the data on the disk (i.e., the disk is full). &lt;br /&gt;
 &lt;br /&gt;
'''Example:'''&lt;br /&gt;
  ! S SFWRITE,DSK&lt;br /&gt;
  ! O FWRITE,DSK&lt;br /&gt;
  ! L T00,E&lt;br /&gt;
  ! R QMONITOR&lt;br /&gt;
  !&lt;br /&gt;
  !==========  WRITE TO A DOS FILE  ==============================&lt;br /&gt;
  !&lt;br /&gt;
  LENGTH 2 &amp;amp; LOCAL AX$,BX$,CX$,DX$        ! Define registers&lt;br /&gt;
             LOCAL FILEHANDLE$            ! Define file handle&lt;br /&gt;
  LENGTH 64 &amp;amp; LOCAL FILENAME$             ! Define file name&lt;br /&gt;
  !&lt;br /&gt;
  LENGTH 100 &amp;amp; LOCAL DATASTRING$          ! Define data string&lt;br /&gt;
  !&lt;br /&gt;
  LENGTH 3 &amp;amp; LOCAL DOSCODE$               ! Define DOS error code&lt;br /&gt;
  LENGTH 37 &amp;amp; LOCAL DOSMESSAGE$           ! Define DOS message&lt;br /&gt;
  !&lt;br /&gt;
  1000 FORMAT DOSMESSAGE$                 ! File input format&lt;br /&gt;
  !&lt;br /&gt;
  100 FORMAT (ET)                         ! Screen format&lt;br /&gt;
  !&lt;br /&gt;
  9999 FORMAT DATASTRING$                 ! File output format&lt;br /&gt;
  !&lt;br /&gt;
  CLEAR                                   ! Initialize variables&lt;br /&gt;
  PRINT (0,100)                           ! Set typewriter mode&lt;br /&gt;
  !&lt;br /&gt;
  PRINT (0) &amp;quot;NAME OF DOS FILE TO OPEN:&amp;quot;   ! Display prompt&lt;br /&gt;
  INPUT (0) FILENAME$                     ! Input file name&lt;br /&gt;
  IF FILENAME$ = &amp;quot;&amp;quot; THEN RUN &amp;quot;QMONITOR&amp;quot;   ! If null, then stop&lt;br /&gt;
  !&lt;br /&gt;
  AX$ = &amp;quot;@3D42@&amp;quot;                          ! Set AX to &amp;quot;OPEN FILE&amp;quot;&lt;br /&gt;
  CX$ = &amp;quot;@0000@&amp;quot;                          ! Set CX to null&lt;br /&gt;
  !&lt;br /&gt;
  DOSFC(AX$,CX$,FILENAME$) EXCP=EXCEPTION ! Open the file&lt;br /&gt;
  !&lt;br /&gt;
  FILEHANDLE$ = AX$                       ! Store file handle&lt;br /&gt;
  !&lt;br /&gt;
  WRITE: PRINT (0) &amp;quot;ENTER STRING TO WRITE TO DOS FILE:&amp;quot;&lt;br /&gt;
         INPUT (0) DATASTRING$&lt;br /&gt;
         IF DATASTRING$ = &amp;quot;&amp;quot; THEN GOTO BOTTOM&lt;br /&gt;
  !&lt;br /&gt;
         AX$ = &amp;quot;@4000@&amp;quot;                   ! Set AX to &amp;quot;WRITE&amp;quot;&lt;br /&gt;
         CX$ = &amp;quot;@0000@&amp;quot;                   ! Set CX to null&lt;br /&gt;
  !&lt;br /&gt;
         DOSRW(AX$,FILEHANDLE$,100,9999) EXCP=EXCEPTION&lt;br /&gt;
  !&lt;br /&gt;
  GOTO WRITE                              ! Loop back for more&lt;br /&gt;
  !&lt;br /&gt;
  BOTTOM: AX$ = &amp;quot;@3E00@&amp;quot;                  ! Set AX to &amp;quot;CLOSE FILE&amp;quot;&lt;br /&gt;
          BX$ = FILEHANDLE$               ! Set BX to file handle&lt;br /&gt;
          CX$ = &amp;quot;@0000@&amp;quot;                  ! Set CX to null&lt;br /&gt;
          DX$ = &amp;quot;@0000@&amp;quot;                  ! Set DX to null&lt;br /&gt;
          DOSMS(AX$,BX$,CX$,DX$)          ! Close the file&lt;br /&gt;
          RUN &amp;quot;QMONITOR&amp;quot;&lt;br /&gt;
  !&lt;br /&gt;
  EXCEPTION:                              ! Exception routine&lt;br /&gt;
  PRINT (0) &amp;quot;WRITE EXCEPTION&amp;quot;             ! Display message&lt;br /&gt;
  OPEN (1) &amp;quot;QERCOMET&amp;quot;                     ! Open error file&lt;br /&gt;
  DOSCODE$ = &amp;quot;D&amp;quot; + HEXASC(SUB(AX$,2,1))   ! Construct key to file&lt;br /&gt;
  READ (1,1000) KEY=DOSCODE$              ! Read error record&lt;br /&gt;
  PRINT (0) &amp;quot;DOS error code: &amp;quot;;DOSCODE$   ! Display DOS error code&lt;br /&gt;
  PRINT (0) DOSMESSAGE$                   ! Display error message&lt;br /&gt;
  INPUT (0) &amp;quot;&amp;quot;                            ! Hold&lt;br /&gt;
  CLOSE (1)                               ! Close error file&lt;br /&gt;
  RUN &amp;quot;QMONITOR&amp;quot;                          ! Exit&lt;br /&gt;
  END&lt;/div&gt;</summary>
		<author><name>Badge</name></author>	</entry>

	</feed>