Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Field Padding

By default the c-treeDB .NET API pad fixed length string fields FIELD_TYPE.CHARS (FIELD_TYPE.FSTRING), FIELD_TYPE.FPSTRING, FIELD_TYPE.F2STRING and FIELD_TYPE.F4STRING with Nulls ('\0') bytes. The field padding property sets the table pad and field delimiter characters to allow proper target key formation. This property allows the c-treeDB .NET API to operate on files created using the FairCom DB ISAM and low level APIs using a fixed string padding strategy that is different from the c-treeDB .NET API default.

Use CTTable.SetPadChar() to set the pad and field delimiter character. CTTable.GetPadChar() retrieves the current pad and field delimiter character.


// set the table pad and delimiter characters to spaces

try

{

ATable.SetPadChar(' ', ' ');

}

catch (CTException err)

{

Console.Write("Set pad character failed with error {0}\n", err.GetErrorCode());

}


The most common strategies for padding fixed string fields are:

  • Pad with Nulls: pad character is '\0' and field delimiter is '\0'
  • Pad with spaces: pad character is ' ' and field delimiter is ' '
  • Pad with spaces and terminate with NUL: pad character is ' ' and field delimiter is '\0'

TOCIndex