We have recently upgraded from 2.01.B to version 3.60. We are finding the FORMAT statement operates somewhat differently. In our code we FORMAT a record to give a comma-separated string of the values. In version 3.60 the string produced is fixed length, with no field separators. Any ideas for a simple way to achieve the 2.01 functionality for formatting a record i.e. the comma separated string? MyString := FORMAT(myRecord);
I think one option would be to use the RECORDREF object and loop through each field in the table. I haven’t used it myself so I don’t know if it is reliable.
[:)]Thanks Paul. This looks workable.
The final solution. In the end we discovered the change between 2.01 and 3.60 was that a tab character was used rather than a comma. So using FORMAT(Rec) as an argument to the attached function recreated enough of the original functionality. PROCEDURE FormatRecord(pInStr: Text) result : Text; VAR vChar : Char; BEGIN // FormatRecord vChar := 9; pInStr := CONVERTSTR(pInStr, FORMAT(vChar), ‘,’); EXIT(pInStr) END;
Only problem is, that on tables with many and large fields, format(rec) could return more than the allowed 1000 characters! SO RecordRef would be a much better approach, now that you are using 360.
Preben, you are quite correct there is a limit. In version 2.01 this was 250 characters, so our code should stand it. RecordRef is a good solution, where I found the difficulties was making a generic function that would work with REC and xREC.
YOu can use Format(rec,1000). It works fine.
Agustin, the original question was how to emulate 2.01 functionality in 3.60 when FORMATing a record. Format(Rec, 1000) generates tab separators rather than commas.