Wednesday, November 5, 2014

Poeplecode Record toString method

Record toString method

This may be one of my favorite shortcuts I've created. For logging or debug it will give you the entire contents of any record in a string. Just like the Java toString class method.

Example


Local Record &rec = CreateRecord(Record.ADM_APPL_PROG);
rem populate record with some values;
MessageBox(0, "", 0, 0, " To String function : %1 ", recToString(&rec));
The output looks like this:
To String function : EARLY_FA_OFFER[abc123,1111,22,12345678,33,2014-11-05,1,4444,55.5]

Function


Function recToString(&R) Returns string;
   Local number &f;
   Local string &txt = &R.name | "[";
   
   For &f = 1 To &R.FieldCount
      If &f > 1 Then
         &txt = &txt | ","
      End-If;
      &txt = &txt | &R.getfield(&f).value;
   End-For;
   
   Return &txt | "]";
End-Function;