110 lines
2.8 KiB
ObjectPascal
110 lines
2.8 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2006. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión: 18-04-2006
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual: 18-04-2006
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
unit EDI_Reader;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes;
|
|
|
|
type
|
|
TEDIFileData = class(TList)
|
|
end;
|
|
|
|
TEDIFile_Reader = class
|
|
private
|
|
FFilename: String;
|
|
FFileData : TEDIFileData;
|
|
protected
|
|
function ProcessLine (const ALine : String) : Boolean; virtual; abstract;
|
|
public
|
|
constructor Create; virtual;
|
|
destructor Destroy; override;
|
|
procedure ReadFile;
|
|
published
|
|
property Filename : String read FFilename write FFilename;
|
|
property FileData : TEDIFileData read FFileData;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, Dialogs, uDataModuleEDI_Sales;
|
|
|
|
{ TEDIFile_Reader }
|
|
|
|
constructor TEDIFile_Reader.Create;
|
|
begin
|
|
FFilename := '';
|
|
FFileData := TEDIFileData.Create;
|
|
end;
|
|
|
|
destructor TEDIFile_Reader.Destroy;
|
|
var
|
|
i : integer;
|
|
begin
|
|
try
|
|
with FFileData do
|
|
for I := Count - 1 downto 0 do
|
|
Dispose(Items[I]);
|
|
finally
|
|
FFileData.Free;
|
|
end;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TEDIFile_Reader.ReadFile;
|
|
var
|
|
i : integer;
|
|
AFichero : TStringList;
|
|
begin
|
|
if (Length(FFilename) = 0) then
|
|
raise Exception.Create('Falta indicar el nombre de todos los ficheros');
|
|
|
|
AFichero := TStringList.Create;
|
|
try
|
|
try
|
|
AFichero.LoadFromFile(FFilename);
|
|
for i := 0 to AFichero.Count - 1 do
|
|
begin
|
|
if not ProcessLine (AFichero.Strings[i]) then
|
|
begin
|
|
//ShowMessage('Error al procesar la línea ' +#13+#10 + AFichero.Strings[i]);
|
|
Break;
|
|
end;
|
|
end;
|
|
except
|
|
on E : Exception do
|
|
begin
|
|
//ShowMessage(E.Message);
|
|
raise;
|
|
end;
|
|
end;
|
|
finally
|
|
FreeAndNIL(AFichero);
|
|
end;
|
|
end;
|
|
|
|
end.
|