How about combining your 2 rectypes into one, like this?
 
Determine inside your procedure which form the data is to take, and set 'Which' accordingly.
 
(Note that when using the case statement inside a type declaration, the record size will use the largest sub-rec size - in this case they are the same size)
 

 

  Type1 = record
    case boolean of
      FALSE: (
        intone: integer;
        strone: array[1..49] of char);
      TRUE: (
        strtwo: array[1..49] of char;
        Inttwo: integer);

 

      Which: boolean;
  end;

 

Procedure LoadTemplate(const APath: String; const AData:TType);

 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jason Coley
Sent: Monday, 14 October 2002 10:29
To: Multiple recipients of list delphi
Subject: [DUG]: Load different types from one procedure?

Is there a way I can load different record type objects using one procedure?

 

I have

 

TType1 = record

            intone: integer;

            strone: array[1..49] of char;

end;

 

TType2 = record

            strtwo: array[1..49] of char;

            Inttwo: integer;

end;

 

These types are stored as files on my system, but I want to have one procedure/function that can load either type by simply passing the path, can you do this.

 

I have something like

 

Procedure LoadTemplate(Path: String; var Data: array of char);

 

But this doesn’t work as the type and array are not compatible.

 

I think this could be a Monday morning thing, but I have had two coffee’s!!!!

 

Jason

Reply via email to