Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign value of enum to some other variable

Tags:

enums

delphi

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

like image 805
Mikayil Abdullayev Avatar asked Aug 11 '11 07:08

Mikayil Abdullayev


1 Answers

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.

like image 82
David Heffernan Avatar answered Oct 11 '22 05:10

David Heffernan