File maintenance

These commands are all specific to the file. You only have to specify a bufferid so that the engine knows which file you want to change something for. The changes are however relevant for all buffers which use that file.


GARBage collection

Garbage collection can be quite important when using the DATAdesign engine. It always makes sure that any buffers whose owning job is no longer present will be removed from memory, possibly also releasing the file that this buffer was using (if it was the only buffer for that file). In Sbasic it can be used together with the routine to release all buffers which may not have been unused by Sbasic programs that were in memory before the current one.

It can be important not only to release the memory which is occupied by the buffer, but also because such buffers may keep a record locked. The only way to make sure no records are locked by buffers from jobs which no longer exist is exactly by collecting garbage.

If you pass a bufferid and the file that the given buffer accesses is disk-based, then any unnecessary whitespace between records will be removed. If there was more whitespace between two record than the IRS, then it will be made shorter. Garbage collection never increases the space between records. Please note that this command is not as safe as the others. If a power failure would occur during garbage collection, then it would probable be very difficult to recover your file !

Sbasic
    GARBAGE #bufferid
    the bufferid always has to be passed explicitly, the
    default buffer is not used automatically. So to call
    it for the default buffer, you should type
        GARBAGE #bufferID
Assembler
    GARB
    bufferid
C
    long DDgarbage(long bufferid);

errors, code,   meaning
itnf    -7      invalid bufferid
...             any file i/o error (should not occur)

Set Inter-Record-Space

You can set the inter-record-space for a certain file with this command. Note that only records which are implemented after this call will be imbedded in the given inter-record-space. As inter-record-space can never grow, not even with garbage collection, it is best to set the inter-record-space immediatly when you create a file.

The inter-record-space is also considered when saving.

The inter-record-space has to be a value between zero and 255.

Sbasic
    SET_IRS #bufferid, irs
    irs : short
Assembler
    SIRS
    bufferid
    short irs
C
    long DDset_irs(long bufferid, short irs);

errors, code,   meaning
itnf    -7      invalid bufferid
orng    -4      inter-record-space not in 0-255 range

Set FileSTatus

This routine allows you to determine whether the file is to be disk-based or memory based. You can give a filename and filedevice in case you want to move the file to disk.

When you make a file disk-based (status=1), then the file is overwritten, so be carefull when giving the filename and filedevice.

When you move the file to memory (status=0), then the file-status is not changed on the medium-file. So if you don't save the file afterwards, and you load it again later (with a USEfile command), then the file will still be disk-based.

When an error occurs during the moving of the file from disk to memory (or vice versa), then BIG problems may occur. This can be tested by comparing the record count before and after the move. The buffer will be unused if problems occur when making the file memory-based.

The medium-file will get the _ddf extension. This extension never has to be specified. When it is specified, it also be included in the filename.

Sbasic
    SETFILEstatus #bufferid, status, filename, filedevice
    status : short
    filename : [string]
    filedevice : [string]
Assembler
    SFST
    bufferid
    short status
    optional string filename
    optional string filedevice
C
    long DDsetfilestatus(long bufferid, short status,
                         char *filename, char *device);

errors, code,   meaning
itnf    -7      invalid bufferid
ipar    -15     status has to be 0 or 1
                no filename
...             any file i/o error (see SAVE and USE)

Set ViewSTatus

This routine allows you to change the view status of the given buffer.

It will always clear the current record (as in NEWrec).

Sbasic
    SETVIEWstatus #bufferid, status
    status : short
Assembler
    SVST
    bufferid
    short status
C
    long DDsetviewstatus(long bufferid, short status);

errors, code,   meaning
itnf    -7      invalid bufferid

CYCLe files

If you want to find out which files are in use on your system, then you can cycle through them with this command. To get the first file in the list, you have to call it with zero as seed. In any other case, the updated value should be used. If you have reached the last file, then the seed will be updated to zero, and the string will be unchanged (null string for Sbasic).

The filename is always returned, so that you can USE the file if you want. A filename is maximum 32 characters long and enough space has to be provided for the return string (no problem in Sbasic).

In Sbasic you can print the filenames of all files like this :

    seed = 0
    REPeat loop
        name$ = CYCLEfile$(seed)
        IF NOT seed THEN EXIT loop
        PRINT name$
    END REPeat loop
Sbasic
    filename$ = CYCLEfile$(seed)
    seed : long
Assembler
    CYCL
    update long seed
    return string filename
C
    long DDcyclefile(long *seed, char *return);

errors, code,   meaning
itnf    -7      seed invalid

PROGS, Professional & Graphical Software
last edited September 3, 1996