NAME

bsaveload - copy memory to file

SYNOPSIS

#include <basic/string.h>

bsave(name, offset, len)
struct string *name;
short offset, len;

bload(name, flag, offset)
struct string *name;
int flag;
short offset;

DESCRIPTION

These functions allow a block of memory to be stored in and retrieved from a file.  Offset is the offset into the current memory segment.  Offset and seg(mach) together specify the address of the beginning of the memory block.  The file is given by the string pointed to by name.  The file has a special format which consists of a one byte magic number followed by the file header followed by the memory contents.  The file header consists of three two byte values: the current segment, the offset and the length of the memory block. 

Bsave copies len bytes from memory to the file.  The segment, offset and length are recorded in the file header.  This function implements the BSAVE statement. 

Bload copies from the file to memory.  If flag is set, the segment, offset and length are read from the file header.  Otherwise only the length is read, the current segment is used and the offset is offset.  If flag is set, the current segment is set to the segment read from the file header.  This function implements the BLOAD statement. 

SEE ALSO

string(inc), seg(mach)
bload(stmt), bsave(stmt)

DIAGNOSTICS

Bload generates error 54 (Bad file mode) if the magic number is incorrect. 

WARNING

Operations involving absolute memory addresses ought not to be used.  However, these functions could be convenient for storing large numeric arrays with low overhead. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber