home *** CD-ROM | disk | FTP | other *** search
- Program TestFlushFileBuffers;
- { THis program will demonstrate the usage of the inline macro }
- { FlushFileBuffers. This is used to guarantee that all info }
- { has actually been written to the disk, and is not held in }
- { memory. }
-
- Type
- Str4 = String[4]; { Componenet type for output file }
- FileType = File of Str4; { File type definition }
-
- Var
- S : Str4; { Variable to be written to file }
- F : FileType; { Output file variable }
- I : Integer; { Loop control variable }
- W : Word; { Result of call to function }
-
- Function FlushFileBuffers( Var F ) : Word;
- { This inline macro will do several things on its way to }
- { flush DOS's file buffers. It first determines if the DOS }
- { version is 3.3 or greater. If so, it will make a call to }
- { a special sub function of Int21 that will do the updating }
- { for us. Otherwise, it will force a duplicate of the file }
- { handle. It then goes on to close this duplicate handle. }
- { If any errors are encountered by the routine, the error }
- { value is returned in the AX register as the result type of }
- { the function. }
- Inline( $5F/ { POP DI }
- $07/ { POP ES }
- $B4/$30/ { MOV AH,30 }
- $CD/$21/ { INT 21 }
- $3C/$03/ { CMP AL,03 }
- $7C/$18/ { JL OTHER }
- $80/$FC/$1E/ { CMP AH,1E }
- $7D/$13/ { JGE OTHER }
- $B4/$45/ { MOV AH,45 }
- $26/$8B/$1D/ { MOV BX,ES:[DI] }
- $CD/$21/ { INT 21 }
- $72/$14/ { JB ERROR }
- $8B/$D8/ { MOV BX,AX }
- $B4/$3E/ { MOV AH,3E }
- $CD/$21/ { INT 21 }
- $72/$0C/ { JB ERROR }
- $EB/$07/ { JMP END }
- { OTHER: }
- $B4/$68/ { MOV AH,68 }
- $26/$8B/$1D/ { MOV BX,ES:[DI] }
- $CD/$21/ { INT 21 }
- { END: }
- $B8/$00/$00 ); { MOV AX,0 }
-
- Begin
- Assign( F, 'test514.dat' ); { Associate Name with file Var }
- Rewrite( F ); { Open the file for Output }
- For I := 1 to 10 Do { Place 10 values into file }
- Begin
- Str( I, S ); { Convert counter to string }
- Write( F, S ); { Write counter to the file }
- End; { }
- W := FlushFileBuffers( F ); { Call the function }
- Writeln( 'Call to FlushFileBuffers yields a ', W );
- { Echo results to the screen }
- Readln; { Pause for viewing of screen }
- End.
-