📄 jcledicom_ansix12.pas
字号:
{**************************************************************************************************}
{ }
{ Ray's Jedi Projects }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is EDICOM_ANSIX12.pas. }
{ }
{ The Initial Developer of the Original Code is Raymond Alexander. }
{ Portions created by Raymond Alexander are Copyright Raymond Alexander. All rights reserved. }
{ }
{ Contributor(s): }
{ }
{**************************************************************************************************}
{ }
{ This is an experimental unit for COM interop with other languages. }
{ }
{ Unit owner: Raymond Alexander }
{ Date created: May 29, 2004 }
{ Last modified: May 30, 2004 }
{ Additional Info: }
{ E-Mail at RaysDelphiBox3@hotmail.com }
{ For latest EDI specific updates see http://sourceforge.net/projects/edisdk }
{ See home page for latest news & events and online help. }
{ }
{**************************************************************************************************}
unit JclEDICOM_ANSIX12;
interface
uses
Windows, ActiveX, Classes, ComObj, StdVcl, EDISDK_TLB,
JclEDI, JclEDI_ANSIX12;
type
IEDICOMInternalInterface = interface
['{72227476-D4D4-448C-9C28-08552373C737}']
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMDelimiters = class(TAutoObject, IEDICOMInternalInterface, IEDICOMDelimiters)
private
FDelimiters: TEDIDelimiters;
protected
function Get_SD: WideString; safecall;
procedure Set_SD(const Value: WideString); safecall;
function Get_ED: WideString; safecall;
procedure Set_ED(const Value: WideString); safecall;
function Get_SS: WideString; safecall;
procedure Set_SS(const Value: WideString); safecall;
function Get_SDLen: Integer; safecall;
function Get_EDLen: Integer; safecall;
function Get_SSLen: Integer; safecall;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMElement = class(TAutoObject, IEDICOMInternalInterface, IEDICOMElement)
private
FDelimitersIntf: TEDICOMDelimiters;
FElement: TEDIElement;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMSegment = class(TAutoObject, IEDICOMInternalInterface, IEDICOMSegment)
private
FDelimitersIntf: TEDICOMDelimiters;
FElementIntf: TEDICOMElement;
FSegment: TEDISegment;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
//
function AddElement: Integer; safecall;
function InsertElement(InsertIndex: Integer): Integer; safecall;
procedure DeleteElement(Index: Integer); safecall;
function AddElements(Count: Integer): Integer; safecall;
function InsertElements(InsertIndex: Integer; Count: Integer): Integer; safecall;
procedure DeleteElements; safecall;
function Get_Element(Index: Integer): IEDICOMElement; safecall;
property Element[Index: Integer]: IEDICOMElement read Get_Element;
function Get_SegmentId: WideString; safecall;
procedure Set_SegmentId(const Value: WideString); safecall;
function Get_ElementCount: Integer; safecall;
property ElementCount: Integer read Get_ElementCount;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property SegmentId: WideString read Get_SegmentId write Set_SegmentId;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMTransactionSet = class(TAutoObject, IEDICOMInternalInterface, IEDICOMTransactionSet)
private
FDelimitersIntf: TEDICOMDelimiters;
FSegmentIntf: TEDICOMSegment;
FTransactionSet: TEDITransactionSet;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
//
function AddSegment: Integer; safecall;
function InsertSegment(InsertIndex: Integer): Integer; safecall;
procedure DeleteSegment(Index: Integer); safecall;
function AddSegments(Count: Integer): Integer; safecall;
function InsertSegments(InsertIndex: Integer; Count: Integer): Integer; safecall;
procedure DeleteSegments; safecall;
function Get_SegmentST: IEDICOMSegment; safecall;
function Get_SegmentSE: IEDICOMSegment; safecall;
function Get_Segment(Index: Integer): IEDICOMSegment; safecall;
function Get_SegmentCount: Integer; safecall;
property SegmentCount: Integer read Get_SegmentCount;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property SegmentST: IEDICOMSegment read Get_SegmentST;
property SegmentSE: IEDICOMSegment read Get_SegmentSE;
property Segment[Index: Integer]: IEDICOMSegment read Get_Segment;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMFunctionalGroup = class(TAutoObject, IEDICOMInternalInterface, IEDICOMFunctionalGroup)
private
FDelimitersIntf: TEDICOMDelimiters;
FSegmentIntf: TEDICOMSegment;
FTransactionSetIntf: TEDICOMTransactionSet;
FFunctionalGroup: TEDIFunctionalGroup;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
//
function AddTransactionSet: Integer; safecall;
function InsertTransactionSet(InsertIndex: Integer): Integer; safecall;
procedure DeleteTransactionSet(Index: Integer); safecall;
function AddTransactionSets(Count: Integer): Integer; safecall;
function InsertTransactionSets(InsertIndex: Integer; Count: Integer): Integer; safecall;
procedure DeleteTransactionSets; safecall;
function Get_SegmentGS: IEDICOMSegment; safecall;
function Get_SegmentGE: IEDICOMSegment; safecall;
function Get_TransactionSet(Index: Integer): IEDICOMTransactionSet; safecall;
function Get_TransactionSetCount: Integer; safecall;
property TransactionSetCount: Integer read Get_TransactionSetCount;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property SegmentGS: IEDICOMSegment read Get_SegmentGS;
property SegmentGE: IEDICOMSegment read Get_SegmentGE;
property TransactionSet[Index: Integer]: IEDICOMTransactionSet read Get_TransactionSet;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMInterchangeControl = class(TAutoObject, IEDICOMInternalInterface, IEDICOMInterchangeControl)
private
FDelimitersIntf: TEDICOMDelimiters;
FSegmentIntf: TEDICOMSegment;
FFunctionalGroupIntf: TEDICOMFunctionalGroup;
FInterchangeControl: TEDIInterchangeControl;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
//
procedure SetDelimiters(const SD: WideString; const ED: WideString; const SS: WideString); safecall;
function AddFunctionalGroup: Integer; safecall;
function InsertFunctionalGroup(InsertIndex: Integer): Integer; safecall;
procedure DeleteFunctionalGroup(Index: Integer); safecall;
function AddFunctionalGroups(InsertIndex: Integer): Integer; safecall;
function InsertFunctionalGroups(InsertIndex: Integer; Count: Integer): Integer; safecall;
procedure DeleteFunctionalGroups; safecall;
function Get_SegmentISA: IEDICOMSegment; safecall;
function Get_SegmentIEA: IEDICOMSegment; safecall;
function Get_FunctionalGroup(Index: Integer): IEDICOMFunctionalGroup; safecall;
function Get_FunctionalGroupCount: Integer; safecall;
property FunctionalGroupCount: Integer read Get_FunctionalGroupCount;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property SegmentISA: IEDICOMSegment read Get_SegmentISA;
property SegmentIEA: IEDICOMSegment read Get_SegmentIEA;
property FunctionalGroup[Index: Integer]: IEDICOMFunctionalGroup read Get_FunctionalGroup;
public
procedure Initialize; override;
destructor Destroy; override;
procedure SetInternalEDIObjectRef(EDIObject: TEDIObject);
end;
TEDICOMFile = class(TAutoObject, IEDICOMFile)
private
FDelimitersIntf: TEDICOMDelimiters;
FInterchangeControlIntf: TEDICOMInterchangeControl;
FEDIFile: TEDIFile;
protected
function Assemble: WideString; safecall;
procedure Disassemble; safecall;
function Get_State: Integer; safecall;
function Get_Data: WideString; safecall;
procedure Set_Data(const Value: WideString); safecall;
function Get_DataLength: Integer; safecall;
property State: Integer read Get_State;
property Data: WideString read Get_Data write Set_Data;
property DataLength: Integer read Get_DataLength;
//
procedure LoadFromFile(const FileName: WideString); safecall;
procedure ReLoadFromFile; safecall;
procedure SaveToFile; safecall;
procedure SaveAsToFile(const FileName: WideString); safecall;
function Get_FileName: WideString; safecall;
procedure Set_FileName(const Value: WideString); safecall;
function Get_Interchange(Index: Integer): IEDICOMInterchangeControl; safecall;
function Get_Options: Byte; safecall;
procedure Set_Options(Value: Byte); safecall;
function AddInterchange: Integer; safecall;
function InsertInterchange(InsertIndex: Integer): Integer; safecall;
procedure DeleteInterchange(Index: Integer); safecall;
function AddInterchanges(Count: Integer): Integer; safecall;
function InsertInterchanges(InsertIndex: Integer; Count: Integer): Integer; safecall;
procedure DeleteInterchanges; safecall;
function Get_InterchangeCount: Integer; safecall;
property InterchangeCount: Integer read Get_InterchangeCount;
function Get_Delimiters: IEDICOMDelimiters; safecall;
property Delimiters: IEDICOMDelimiters read Get_Delimiters;
property FileName: WideString read Get_FileName write Set_FileName;
property Interchange[Index: Integer]: IEDICOMInterchangeControl read Get_Interchange;
property Options: Byte read Get_Options write Set_Options;
public
procedure Initialize; override;
destructor Destroy; override;
end;
implementation
uses ComServ, SysUtils;
{ TEDICOMElement }
function TEDICOMElement.Assemble: WideString;
begin
Result := FElement.Assemble;
end;
destructor TEDICOMElement.Destroy;
begin
FDelimitersIntf.ObjRelease;
FDelimitersIntf := nil;
FElement := nil;
inherited;
end;
procedure TEDICOMElement.Disassemble;
begin
FElement.Disassemble;
end;
function TEDICOMElement.Get_Data: WideString;
begin
Result := FElement.Data;
end;
function TEDICOMElement.Get_DataLength: Integer;
begin
Result := FElement.DataLength;
end;
function TEDICOMElement.Get_Delimiters: IEDICOMDelimiters;
begin
FDelimitersIntf.SetInternalEDIObjectRef(FElement.Delimiters);
Result := FDelimitersIntf;
end;
function TEDICOMElement.Get_State: Integer;
begin
Result := Integer(FElement.State);
end;
procedure TEDICOMElement.Initialize;
begin
inherited;
FDelimitersIntf := TEDICOMDelimiters.Create;
FDelimitersIntf.ObjAddRef;
end;
procedure TEDICOMElement.SetInternalEDIObjectRef(EDIObject: TEDIObject);
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -