Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database like functions in yab.
#1
The fileblock library brings database like functions to yab.

This allows one to read data from a large file and replace just one portion of the file, a record or even just one field of a record.

fileblock.yab information:

exported subroutines


openfile (fil$, recordlength, numberoffields)

Opens a file for block access, one must plan ahead.
fil$... The name ofd the file to open.
recordlength... The size of the block or record.
numberoffields...The number of data elements that each block contains.
Returns the filehandle number to identify this file for future actions.

note
One may open the same file, fil$ more than once and use different number of fields
for each instance. Thus allowing one to have different types of data elements
stored in the same data file. The recordlength must remain the same for all instances.


Field( filehandle,fieldnumber, fieldname$, fieldlength)

One must have a field statement for each data element in the block.

Specifies the length in bytes and name of each data element.
filehandle... the number that identifies the file.
fieldnumber the number of the field starting at 1
fieldname$... the name to identify this field with.
fieldlength... The number of bytes allocated to this data element.
Returns 1, ok or 0, bad field number.


lset(filehandle,fieldname$,data$)
rset(filehandle,fieldname$,data$)

Complimentary statements for placing data into a field buffer for writinmg
to a record. lset places the data on the left end of the field and rset
places it on the right end. if the data passed in is larger than the field,
it is truncated to fit. If it is shorter than the field, the extra spaces
are filled with the space character, " ". either after, lset or before, rset
the data.

filehandle... The number that identifies the file.
fieldname$... The name of the data element.
data$... The information to be stored.

write_block(recordnumber, filehandle)

Writes or over-writes a block ( record ) to the data file with the data
in the buiffer that was set with lset, rset or read_block.
filehandle.. the file identifier.
recordnumber... The number of the record in the file ( the first record
is record 0, the next record is one etc.) if recordnumber is -1 the
record is appended to the end of the file.

read_block(recordnumber, filehandle)

Reads the data of the record recordnumber into the data buffer.
recordnumber the record to read
filehandle the identifier for the file.
Returns the number of the next record.


readfield$(File, fieldname$)

Reads the data held in the buffer for fieldname$
File... The file identifier
fieldname$... The name of the field to read.


lof(filehandle)
numberofrecords(filehandle)

Returns the number of records in the file.
filehandle... The file identifier.
Reply
#2
I keep looking at this and wondering if I should try my hand at a spreadsheet ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting