Sbasic SAVEfile #bufferid, filename, filedevice, over filename : [string] filedevice : [string] over : short[0] Assembler SAVE bufferid optional string filename optional string filedevice short overwrite status C long savefile(long bufferid, char *filename, char *filedevice, short over); errors, code, meaning itnf -7 invalid bufferid drfl -11 drive full fex -8 file already exists ... any other file i/o error
DEFine PROCedure backup(bid, name$, dev$, over) keep=bufferID : DEFbuffer=bid keepi=indexID : DEFindex=0 keepv=VIEWstatus : SETVIEWstatus 1 dd_err=0 SAVEinit name$, dev$, over IF dd_err THEN RETURN FIRSTrec REPeat loop SAVErec : IF dd_err THEN EXIT loop NEXTrec : IF dd_err THEN EXIT loop END REPeat loop SAVEfinish SETVIEWSTATUS keepv : DEFbuffer keep : DEFindex keepi END DEFine backupThis program changes the viewstatus to view only as this makes sure that all records are actually saved. This program does however not return any error, contrary to the routine in the engine. It does show how to make sure that all statusses are preserved when the routine ends. A similar routine could be implemented if you want to save all the record in a certain index, or if you want to save only certain fields.
Sbasic BACKfile #bufferid, filename, filedevice, over filename : [string] filedevice : [string] over : short[0] Assembler BACK bufferid optional string filename optional string filedevice short overwrite status C long backfile(long bufferid, char *filename, char *filedevice, short over); errors, code, meaning itnf -7 invalid bufferid drfl -11 drive full fex -8 file already exists fdiu -9 Save Record Sequence channels still open ... any other file i/o error
Sbasic SAVEinit #bufferid, filename, filedevice, over filename : string filedevice : [string] over : short[0] Assembler SAVI bufferid string filename optional string filedevice short overwrite status C long saveinit(long bufferid, char *filename, char *filedevice, short over); errors, code, meaning itnf -7 invalid bufferid drfl -11 drive full fex -8 file already exists fdiu -9 in use, there is still a channel open, should call SAVEfinish ... any other file i/o error\subsubsection{SAVe Record} The current record will be saved. You have to make sure that every record is only implemented once, or you will have problems when loading. A record has to have been implemented if you want to save it (it has to have a recordID). This routine also takes the IRS into account. Also note that the channel should be closed with SAVEfinish if an error occurs.
Sbasic SAVErec #bufferid Assembler SAVR bufferid C long saverec(long bufferid); errors, code, meaning itnf -7 invalid bufferid drfl -11 drive full orng -4 this is a new record, not accepted ... any other file i/o error\subsubsection{SAVe record sequence Finish} Close the file for the save record sequence for the given buffer.
Sbasic SAVEfinish #bufferid Assembler SAVF bufferid C long savefinish(long bufferid); errors, code, meaning itnf -7 invalid bufferid
dd_err=0 nrf=NRfields(#merge) REMark array with fieldid in old file, fieldid in current file DIM ref(nrf,2): ref(0,1)=0 : ref(0,2)=0 REMark add the fields j=0 FOR i=1 TO nrf name$=CYCLEfields(#merge,j,t) ADDfield name$,t ref(i,1)=j : ref(i,2)=fieldID(name$) END FOR i REMark copy all the fields FIRSTrec #merge REPeat loop NEWrec FOR i=0 to nrf length=GETfield(#merge, ref(i,1), maxlen, buffer) SETfield ref(i,2), length, buffer END FOR i IMPLEMENT NEXTrec #merge IF dd_err THEN EXIT loop END REPeat loopPROGS, Professional & Graphical Software