Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 11 of 11 total
Thread Script help needed please..
Thu, Sep 27 2018 11:58 PMPermanent Link

Ian Branch

Avatar

If anybody is interested, this is the code I used to export the Query (tqParts).

{code}
procedure TMainForm.Button1Click(Sender: TObject);
var
 Stream: TFileStream;
 i, iCount: Integer;
 OutLine: Ansistring;
 sTemp: Ansistring;
begin
 //
 iCount := 0;
 //
 tqParts.Open;
 //
 Stream := TFileStream.Create('.\MYOBPartsExport.txt', fmCreate);
 //
 try
   while not tqParts.Eof do
   begin
     // You'll need to add your special handling here where OutLine is built
     OutLine := '';
     for i := 0 to tqParts.FieldCount - 1 do
     begin
       sTemp := tqParts.Fields[i].AsString;
       // Special handling to sTemp here
       sTemp := StringReplace(sTemp, ',', '-', [rfReplaceAll, rfIgnoreCase]);
       //
       OutLine := OutLine + sTemp + ',';
     end;
     // Remove final unnecessary ','
     SetLength(OutLine, Length(OutLine) - 1);
     // Write line to file
     Stream.Write(OutLine[1], Length(OutLine) * SizeOf(AnsiChar));
     // Write line ending
     Stream.Write(sLineBreak, Length(sLineBreak));
     Inc(iCount);
     tqParts.Next;
   end;
 finally
   Stream.Free; // Saves the file
 end;
 //
 tqParts.Close;
 //
 Panel2.Caption := 'Processing Completed..';
 //
end;
{code
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image