Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a collection of named constants for function

Status
Not open for further replies.

JCooL

Programmer
Oct 21, 2001
89
0
0
US
Hi there,
Sorry my English

In this case i want to define the Enum Statement like VBasic, when i use my function i only select a item of my defined constants collection.

i.e

function sum(x,y:integer):integer;
sum:=x+y;
end; {but x and y are a constants collection of numbers to select when i call the function}


Thank In Advance

 
I'm not sure I understand quite what you're asking but here's an example of enumerated types in Delphi.

Declaration:
Code:
type
 DayOfWeek = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);

Use:
Code:
var
 today: DayOfWeek;

The only values we can assign to the variable "today" are those listed (enumerated) in the DayOfWeek type declaration. e.g.
Code:
today := Mon;

Hope this helps!

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
if you make one function like this for any kind of array...

function ItemArray(const aArray:array of integer;id:integer):integer; // or any other...
begin
Result:=aArray[id];
end;

//when you want to use then

value:=ItemArray([1,2,4,5,6],4); or any value;
or even you can make
function ItemArray(const aArray:array of const;id:integer):variant; // or any other... etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top