unit Conv_DFI;


function Main( QSystem        : Variant;
               SourceFileName : Variant;
               DestFolder     : Variant;
               LogFileName    : Variant;
               SaveFileName   : Variant;
               ConvResult     : TConvertResult): AnsiString;
var
  QDASInterface : TQSSTATConverterInterface; // variable for qs-STAT interface
begin
  QDASInterface := TQSSTATConverterInterface.Create( QSystem);
  try
    // reset internal structures
    QDASInterface.ResetQSSTAT;

    if ( QDASInterface.ErrorCode = 0) then
    begin
      if (ConvResult <> nil) then
      begin
        ConvResult.ScriptVersion := '2010-04-26';
        ConvResult.SourceFiles.Text := SourceFileName;
      end;
      // open source file
      QDASInterface.Open_QDASFile(SourceFileName);
      QDASInterface.TargetDir := DestFolder;
      // write DFQ with unique filename
      QDASInterface.SaveToDFQFile(ChangeFileExt(ExtractFileName(SourceFileName),'.DFQ'));
      // reset internal structures
//      QDASInterface.ResetQSSTAT;
    end;
  finally
    // free resources
    QDASInterface.Free;
    QDASInterface := NIL;
  end;
end;

function CheckIsFile( QSystem        : Variant;
                      SourceFileName : Variant) : Integer;
begin
  Result := -1;
  if ( Pos( '.DFI', AnsiUpperCase( ExtractFileName( SourceFileName))) > 0) then
  begin
    Result := 0;
  end;
end;


end.
