BdLm
asked on
convenient change from type def to a string value and back
i'm looking for a clever solution for this task convert myModes to a String Value (and convert it back to a mymode value);
below my current approach to this task
type myModes = (all, none, ever, today, now, yesterday);
function MyMode2Str( value : myModes) : String;
begin
if MyMode=all then result='all';
if MyMode=none then result='none';
...
...
end;
function AnyStr2MyMode(value : String) : myMode;
begin
if MyMode='all' then result=all;
if MyMode='none' then result=none;
...
...
end
below my current approach to this task
type myModes = (all, none, ever, today, now, yesterday);
function MyMode2Str( value : myModes) : String;
begin
if MyMode=all then result='all';
if MyMode=none then result='none';
...
...
end;
function AnyStr2MyMode(value : String) : myMode;
begin
if MyMode='all' then result=all;
if MyMode='none' then result=none;
...
...
end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is an alternative method using the runtime information (RTTI) but it's a bit complex. This method is the simplest one.