I just did a quick program (8.03) to generate a UDT of the record layout of DBF files. The file output could be read perfectly in either the PB IDE or Notepad with the correct space formatting. It turned out that the field defs(y).nme which is defined as STRING * 11 and contains the names of the fields in the DBF record was padded with chr$(0) if less than 11 characters but the PRINT #fo statement appears to convert them automatically to spaces whilst the STRING t prepared identically for display in a textbox did not. Here is the Code
and here is the file output without the REPLACE
Even if I just print the entire string i.e PRINT #fo, t all the chr$(0)'s appear to be replaced with spaces and it looks exactly as above
Code:
FOR x = 33 TO head.lenhd - 1 STEP 32 GET fi, x, defs(y) SELECT CASE defs(y).Ftype CASE "C" s = " 'a string" CASE "N" s = " 'a number" CASE "D" s = " 'a date" CASE "L" s = " 'true or false" CASE "M" s = " 'a memo address" END SELECT '********************************************************************************************** 'this line is needed for proper display in a textbox %Trept but not the printed string REPLACE CHR$(0) WITH " " IN defs(y).nme '********************************************************************************************** IF DoInc THEN PRINT #fo, SPACE$(4) & defs(y).nme & " as STRING * " & FORMAT$(defs(y).FldLen) & s t = t & SPACE$(4) & defs(y).nme & " as STRING * " & FORMAT$(defs(y).FldLen) & s & $CRLF INCR y NEXT IF DoInc THEN PRINT #fo, "End Type" t = t & "End Type" & $CRLF CONTROL SET TEXT CBHNDL, %Trept, t
Code:
TYPE UE_Fields INDEX AS STRING * 6 'a number RACEDATE AS STRING * 8 'a date TRK AS STRING * 3 'a string TRACKNAME AS STRING * 20 'a string RN AS STRING * 2 'a string TYP AS STRING * 3 'a string DESC AS STRING * 30 'a string CONDITIONS AS STRING * 20 'a string DIST AS STRING * 4 'a number PRIZE AS STRING * 10 'a number NR AS STRING * 2 'a number TC AS STRING * 1 'a string RACETIME AS STRING * 6 'a number TRACKAVG AS STRING * 6 'a number SOT AS STRING * 5 'a number CRAT AS STRING * 4 'a number WRAT AS STRING * 4 'a number SRAT AS STRING * 4 'a number END TYPE
Comment