Delphi Notes
The following are things to consider when you use Delphi to develop your Pervasive PSQL application.
Unlike older versions of Pascal, Delphi’s string type (without a length specifier) is dynamic and null terminated. This means that you are not guaranteed to have memory allocated to the string buffer until you assign it a value. This means when using the type string, you need to pad it large enough to hold the expected results. Using the StringOfChar() function, you can assign a blank string large enough to accommodate the expected return value from Btrieve, as illustrated in the following example:
CustKeyBuffer: string; //long string
CustBufLen : word;
   //MAX_KEY_LEN is 255 since BTRV() always passes
     //255 for the Key Length :
CustKeyBuffer     := StringOfChar(‘ ‘, MAX_KEY_LEN);
CustBufLen := SizeOf(CustRec);
Status := BTRV(B_GET_FIRST, CustPosBLock, CustRec,              CustBufLen, CustKeyBuffer, 0);
      {CustKeyBuffer now has the value of the key for}
      {the record retrieved}