繁体   English   中英

如何在 Delphi 中向这种数组添加项目?

[英]How can i add an item to this kind of array in Delphi?

我有一个名为 apps 的变量,我认为它是一个动态数组:

  apps2      = array of app3;

  app3 = class(TRemotable)
  private
    Fname_: appNameType;
    Fid: appIdType;
  published
    property name_: appNameType  Index (IS_UNQL) read Fname_ write Fname_;
    property id:    appIdType    Index (IS_UNQL) read Fid write Fid;
  end;

我有一个 inititeTechnicalRegistration 类,我必须将一些值传递给它的 apps 属性。 我该怎么做?

initiateTechnicalRegistration_Type = class(TRemotable)
  private
    FpartnerName: partnerNameType;
    FpartnerOrganizationIdentifier: partnerOrganizationIdentifierType;
    Fapps: apps2;
    Fapps_Specified: boolean;
    Fdescription: descriptionType;
    Fdescription_Specified: boolean;
    FcontactEmail: contactEmailType;
    FrequestedRole: Array_Of_roleType;
    FpublicKey: string;
    FpartnerAddress: partnerAddressType;
    FpartnerAddress_Specified: boolean;
    FpartnerURL: partnerURLType;
    FpartnerURL_Specified: boolean;
    procedure Setapps(Index: Integer; const Aapps2: apps2);
    function  apps_Specified(Index: Integer): boolean;
    procedure Setdescription(Index: Integer; const AdescriptionType: descriptionType);
    function  description_Specified(Index: Integer): boolean;
    procedure SetpartnerAddress(Index: Integer; const ApartnerAddressType: partnerAddressType);
    function  partnerAddress_Specified(Index: Integer): boolean;
    procedure SetpartnerURL(Index: Integer; const ApartnerURLType: partnerURLType);
    function  partnerURL_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property partnerName:                   partnerNameType                    Index (IS_UNQL) read FpartnerName write FpartnerName;
    property partnerOrganizationIdentifier: partnerOrganizationIdentifierType  Index (IS_UNQL) read FpartnerOrganizationIdentifier write FpartnerOrganizationIdentifier;
    property apps:                          apps2                              Index (IS_OPTN or IS_UNQL) read Fapps write Setapps stored apps_Specified;
    property description:                   descriptionType                    Index (IS_OPTN or IS_UNQL) read Fdescription write Setdescription stored description_Specified;
    property contactEmail:                  contactEmailType                   Index (IS_UNQL) read FcontactEmail write FcontactEmail;
    property requestedRole:                 Array_Of_roleType                  Index (IS_UNBD or IS_UNQL) read FrequestedRole write FrequestedRole;
    property publicKey:                     string                             Index (IS_UNQL) read FpublicKey write FpublicKey;
    property partnerAddress:                partnerAddressType                 Index (IS_OPTN or IS_UNQL) read FpartnerAddress write SetpartnerAddress stored partnerAddress_Specified;
    property partnerURL:                    partnerURLType                     Index (IS_OPTN or IS_UNQL) read FpartnerURL write SetpartnerURL stored partnerURL_Specified;
  end;

  initiateTechnicalRegistration = class(initiateTechnicalRegistration_Type)
  private
  published
  end;

所以我想在运行时或其他可能的方式中从一些 TEdit 传递一些值给这个,但我以前从未使用过这些类型的变量,我该怎么做?

启动TechnicalRegistration1.apps :=

下面是将项目添加到 Apps 数组的方法的代码:

// Function return the index allocated in the array
function TForm1.AddApp(Value: App3): Integer;
begin
    Result := Length(FApps);
    SetLength(FApps, Result + 1);
    FApps[Result] := Value;
end;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM