Mikayil Abdullayev
Mikayil Abdullayev

Reputation: 12367

Assign value of enum to some other variable

I have the following enum in Delphi:

type TChangingDataSetState=(Inserting=1,Editing,Deleting)
......
var
ChangingDSSsate:TChangingDataSetState;

In BeforePost event I check if the dataset in Insert mode then I

 ChangingDSState:=Inserting
else
 ChagingDSState:=Editing

Let's say the dataset is in edit mode, it means my ChangingDSState var will get evuluated to 2(Editing). Now I want to know how I can then use that number to pass it as an argument to a procedure

Upvotes: 8

Views: 1656

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

I assume you want the ordinal value rather than the enumerated value. You get that with ord().

So, ord(ChagingDSState) is an integer expression with a value of 2 when ChagingDSState equals Editing.

Upvotes: 12

Related Questions