>>I thought the varchar field type would save space in the file size of my table?
>>
>>I have a table that has thousands of records and many character fields, I thought by changing the character fields to varchar the table size would be reduced?
>>
>>Have I got this all wrong?
>
>The table size is not reduced. As I understand it, VFP VarChar is there mainly to improve interoperability with SQL Server. IIRC another effect is different handling of trailing spaces/column padding. See the help: "HELP FIELD TYPES" for VarChar, including the code sample.
The other difference is the length of the field, as returned by the len() function - it shouldn't include the padding, i.e. it would return the position of the rightmost character before the first chr(0). Seek() should also work differently - wherever we had implied padding with regular character fields, we may have strings of different lengths, or at least strings behaving as if of different lengths.
With varchar fields, you find
calc max(len(cfield)) to maxlen
there is no more the need for
calc max(len(trim(cfield))) to maxlen