Solved

Property with a pick list

Posted on 2009-07-03
1
351 Views
Last Modified: 2013-11-23
I want to create a delphi object with a property which can be
one of the follow values:

(PENDING,DOWN,UP,SLEEPING....)

So that in my code i can do things like that:

Actor.Status := PENDING;
Node.Status := UP;

Should I define my const value and use them in a property?

Someone can show me how to do it, plz?
 
0
Comment
Question by:jaja2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
btframework earned 500 total points
ID: 24771201
type
  TMyStatus = (PENDING, DOWN, UP, SLEEP);

  TActor = class()
  private
    FStatus: TMyStatus;

  public
    property Status: TMyStatus read FStatus write SetStatus;
  endl

Something like that.

If TActore is not your class then you can define enumeration like:

type
  TMysStatus = (PENDING = 100, DOWN = 200, UP = 5, SLEEP = 1);

where 100, 200, 5 and 1 are the actual values defined for the class.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to call a form that is in a DLL  from an application? 13 86
LAN or WAN ? 11 105
Firemonkey android show image from resource ? 1 56
Firemonkey Queue list 1 26
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question