Table example: Variable data

Tab(Xpos,Ypos:number;Htabs:list;Vspace:number):tableHandle;
OpenFile(Name:string):fileHandle
ReadCSV(var Handle:fileHandle;var Lx:list;[Separator:string[1]]);

You need a separate CSV file to supply the data for this RS/2 file.

// REDTITAN RS2 CONTROL

paper('a1',false);

if paramstr(1)='1' then

begin // first page only
   filename:=paramstr(2);
  if fileexists(FILENAME) then fx:=openFile(FILENAME) else
    begin
       filename:=browse('CSV file','','CSV files (*.csv)|*.csv|All files (*.*)|*.*');
      if trim(filename)='' then halt(1);
       fx:= openfile(filename);
    end;

   csv_buffer:=[];
  readcsv(fx,CSV_BUFFER);
   headings:=csv_buffer;

end;

orient('L');
pen(1);
tx:= tab(200,800,[600],5);
tab_align(tx,'l');
tab_pad(tx,40);

// display headings on every page

text(200,200,Filename);

for i:=0 to pred(length(headings)) do tab_cell(tx,list_strings(headings,i));

tab_nextrow(tx,true);

repeat

readcsv(fx,CSV_BUFFER);
for i:=0 to pred(length(csv_buffer)) do tab_cell(tx,trim(list_strings(csv_buffer,i)));
if tab_nextrow(tx)>12600 then break;

until eof(fx);

if eof(fx) then halt(1);