Using Delphi 2010 ... I have a set of binary properties that I want to combine together. I defined it as such ...
type TTableAttributeType = ( tabROOT = 1, tabONLINE = 2, tabPARTITIONED = 3, tabCOMPRESSED = 4, ); // Make a set of of the Table Attribute types... type TTableAttrSet = Set of TTableAttributeType;
In my MAIN.PAS module, I can create a variable of type TTableAttrSet. Another module, UTILS.PAS must also understand the type TTableAttrSet. This is stated in the USES articles ...
Main USES Util ... Util USES Main (The second uses the sentences in the implementation section, so I don't get any circular help problems ....
So far so good. My problem is that I need to pass a var variable of type TTableAttrSet FROM main to Utils.
In main.pas
procedure TForm1.Button1Click(Sender: TObject); var TabAttr : TTableAttrSet; begin TestAttr (TabAttr); end;
and in utils.pas I have
procedure TestAttr(var Attr: TTableAttrSet); begin Attr := [tabROOT, tabCOMPRESSED]; end;
When I try to do this, I have several problems ... Task 1). When I define my procedure definition at the top of utils.pas,
procedure TestAttr(var Attr: TTableAttrSet);
I get an error that TTableAttrSet is an Undeclared Identifier. This makes sense because the definition is in Main.pas, and "use Main.pas" AFTER the definition of my procedures. How do I get around this? At the moment, I have duplicated the definition of the type TTableAttrSet at the top of the Utils.pas file as well as Main.pas, but this does not seem to be the correct path.
Task 2). The big problem I am facing is a compilation error. on the calling line in Main.pas
TestAttr(TabAttr);
I get the error "The types of the real and formal parameters of var must be identical." As far as I know, they are identical. What does the compiler complain about?