SECTION 6
Conversions and Interfaces
6-6 PEN*KEY
R
6200/6300 Hand-Held Computer Programmer’s Reference Guide
Files
Since each PEN*KEY 6000 Series Computer has a reset button, there is a
possibility that the user could press it at any time. In order to maintain data
integrity the application must make sure that all file writes are committed to
disk. This should be done at the completion of every transaction, e.g. a sales
invoice. Applications should
fflush()
all open streams. Also, because of DOS
disk buffers and the fact that DOS does not update the directory entry for a file
with each write, applications must do one of the following:
1. Close and reopen all files.
2. Call DOS function 68h for each open file. All data still in DOS disk buffers
is written to disk immediately, and the file's directory entry is updated.
EXAMPLE:
Example code for Borland C++:
asm mov ah,0x68
asm mov bx,filehandle
asm int 0x21
3. Use DOS function 5D01h, which flushes DOS buffers and updates the
directory entries for all open files. Example code for Borland C++:
int FileCommit(void)
{
REGS regs;
SREGS sregs;
// Parameter table used by function 5d01h. Only process_id and
// computer_id are used.
struct {
unsigned int ax;
unsigned int bx;
unsigned int cx;
unsigned int dx;
unsigned int si;
unsigned int di;
unsigned int ds;
unsigned int es;
unsigned int RESERVED;
unsigned int computer_id;
unsigned int process_id;
} dos_parm;
dos_parm.computer_id = 0;
//set current computer
dos_parm.process_id = getpsp();
//set current process
sregs.ds = FP_SEG(&dos_parm);
//set up address of parameter table
regs.x.dx = FP_OFF(&dos_parm);
regs.x.ax = 0x5d01;
//commit all files to disk
intdosx(®s,®s,&sregs);
if (regs.x.cflag)
return regs.x.ax;
// if error return code completed ok
return 0;
}
Even if files are committed to disk, a reset can still occur at such a time as to
leave a partial record in a file. Verify files such as the transaction stream at
program start, and truncate or mark any invalid records as void.
Remove any code used for formatting memory cards for the 4000 Series. PC
memory cards can be formatted on the PEN*KEY 6000 Series Computer by
loading the CardSoft software and executing FORMAT.COM.
6. Conversions and
Interfaces