× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi.  We are trying to use variable length fields in a file, but so far there 
doesn't seem to be any advantage to them.

As a proof-of-concept, we created a file with eight fields, all variable 
length.  We set the maximum field sizes at 10 bytes, 20, 30, 40, etc.  After 
compiling the file, we added three records.  The record length was 376 bytes; 
the total size of the file was 32768 bytes.  The two-byte length at the 
beginning of each field was correct for the data in that field, so everything 
seemed okay.

We then created a fixed-length file.  It had the same eight fields, with the 
same lengths (leaving off the VARLEN keyword, obviously).  The same three 
records were added to this file after it was compiled.  This time, the record 
size was 360 bytes and the total size of the file was 24576 bytes.

That did not match what we were expecting to see at all.  We thought that using 
variable length fields would take up only as much storage as they really need.  
Why then would a variable length file be *longer* than a fixed length file.

(I should mention that none of the data in the fields came anywhere close to 
the maximum size of that field.  Had we filled the fields to their maximum, 
then I would expect the variable length file to be larger than its fixed length 
counterpart, owing to the presence of the length bytes.)

Just for the fun of it, we created another variable length file, this time 
specifying VARLEN(10) on each field.  We thought that *maybe* the absence of an 
allocation length was causing these odd results.  But in the end, it was the 
same result:  a 376 byte record with a 32768 byte file.

We looked to see if there was a keyword on the compile that we were missing, 
but that doesn't seem to be the case.

Does anyone else use variable length fields?  Is this normal, that a var-len 
file should be larger than a fix-len file?  Is there something we are missing?  
Any help or information would be appreciated, because if we're doing this 
properly, then there doesn't seem to be any value to variable-length fields.

Thanks.

David Bocian

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.