// Write Paradox table to comma-delimited file using command-line program. // Assumes Alias DBGADS is properly configured. // efg, 20 March 1998. {$APPTYPE CONSOLE} PROGRAM SaveGATSby; USES DBTables, // TTable SysUtils; // FormatDateTime VAR Filename: STRING; Out : TextFile; Table : TTable; BEGIN IF ParamCount > 0 THEN Filename := ParamStr(1) ELSE Filename := 'GATSBY.TXT'; AssignFile(Out, Filename); REWRITE(Out); Table := TTable.Create(NIL); TRY WITH Table DO BEGIN Active := FALSE; DatabaseName := 'DBGADS'; // directory or alias TableName := 'GADEVENT.DB'; Exclusive := FALSE; ReadOnly := TRUE; Active := TRUE; First; WHILE NOT Table.EOF DO BEGIN WRITELN(Out, '"',FieldByName('Unit').AsString,'",', '"',FieldByName('Year').AsInteger,'",', '"',FieldByName('Event Number').AsInteger,'",', '"',FieldByName('Event Type').AsString,'",', '"',FormatDateTime('mm/dd/yyyy''"'',''"''hh:nn', FieldByName('Event Start').AsDateTime),'",', '"',FormatDateTime('mm/dd/yyy''"'',''"''hh:nn', FieldByName('Event End').AsDateTime),'",', '"',FieldByName('Available MW Capacity').AsInteger,'",', '"',FieldByName('Primary Cause Code').AsString,'",', '"',FieldByName('Primary Description').AsString,'",', '"',FieldByName('Secondary Cause Code').AsString,'",', '"',FieldByName('Secondary Description').AsString,'",', '"',FieldByName('Reason').AsString,'",', '"',FieldByName('Exclude From GADS Report').AsInteger,'"'); Next; END; CloseFile(Out); Close END FINALLY Table.Free END END {SaveGATSby}.