Board index » delphi » Passing User Defined Types to a Procedure

Passing User Defined Types to a Procedure

I'm trying to Pass an array of a user defined type to a Procedure but I'm
not having much luck. I need to Define my recordtype before the public
section, but I'm not sure how.

I'm trying........

Interface
..
..
{Public}
    procedure LoadTableInfo(var TableInfo: array of TTableinfo) ;

Implementation

Type
  TTableInfo = record  {stores SQL Table Information }
    Table: string[10] ;
    PKeys: array[1..5] of string
  end ;

Var
  Tableinfo: array[1..20] of TTableinfo ;

procedure TfrmAudit.LoadTableInfo(var TableInfo: array of TTableInfo) ;
var
  indx, subindx: integer ;
  sPKeys: string ;

  begin

   Does something.........

end ; {Proc}

any suggestions, thanks

Keric Donnelly

 

Re:Passing User Defined Types to a Procedure


Quote
Keric Donnelly wrote:

> I'm trying to Pass an array of a user defined type to a Procedure but I'm
> not having much luck. I need to Define my recordtype before the public
> section, but I'm not sure how.

> I'm trying........

> Interface
> ..
> ..
> {Public}
>     procedure LoadTableInfo(var TableInfo: array of TTableinfo) ;

> Implementation

> Type
>   TTableInfo = record  {stores SQL Table Information }
>     Table: string[10] ;
>     PKeys: array[1..5] of string
>   end ;

> Var
>   Tableinfo: array[1..20] of TTableinfo ;

> procedure TfrmAudit.LoadTableInfo(var TableInfo: array of TTableInfo) ;
> var
>   indx, subindx: integer ;
>   sPKeys: string ;

>   begin

>    Does something.........

> end ; {Proc}

> any suggestions, thanks

> Keric Donnelly

Just move the type declaration into your intreface section ...

Interface
..
Type
  TTableInfo = record  {stores SQL Table Information }
    Table: string[10] ;
    PKeys: array[1..5] of string
  end ;
..
{Public}
    procedure LoadTableInfo(var TableInfo: array of TTableinfo) ;

Chris Jobson

Other Threads