Welcome to Pascal wpflum, this is an example for defining and creating an object like the one you describe, hope it helps.
type
TSomeType = (stApple, stOrange);
TSomeClass = class
private
FName: string;
DateCreated: TDateTime;
ObjType: TSomeType;
procedure SetName(Value: string);
public
property Name: string read FName write SetName;
property Created: TDateTime read FDateCreated;
property ObjType: TSomeType read FObjType write FObjType;
constructor Create;
end;
const
TSomeTypeNames: array[TSomeType] of string = ('Apple', 'Orange');
implementation
procedure TSomeClass.SetName(Value: string);
begin
if Value <> EmptyStr then
FName := Value
else
raise Exception.Create('Name cannot be blank');
end;
procedure TSomeClass.Create;
begin
FName := EmptyStr;
FDateCreated := Now;
FObjType := stApple;
end;
end.
{ Somewhere else in project }
var
MyFruit: TSomeClass;
begin
MyFruit := TSomeClass.Create;
try
Apple.Name := 'My Orange';
Apple.Type := stOrange;
ShowMessage(TSomeTypeNames[Apple.ObjType]);
finally
MyFruit.Free;
end;
end;
Let me go step by step to ask questions.
Ok, here I'm going to show how much of a newbie I am to Pascal, I haven't yet used a 'Type' procedure, what exactly does the line 'TSomeType = (stApple, stOrange);' do??
The statements
private
FName: string;
DateCreated: TDateTime;
ObjType: TSomeType;
procedure SetName(Value: string);
are all contained by the class and do not 'leak' out into the real world, correct?
The statements
public
property Name: string read FName write SetName;
property Created: TDateTime read FDateCreated;
property ObjType: TSomeType read FObjType write FObjType;
constructor Create;
are what the public sees of the class meaning myclass.xxxxxxx where xxxxxxx would be Name, Created,ObjType, Create, Correct??
The Create function is there to initialize the object, correct??
Is a the 'Constructor Create;' used when the item is a function and not a property or is that something special for the 'Create' name??
Bear with me as the past couple of days I've been having Sinus problems which means lack of quality sleep which equals a head stuffed with cotton balls. I tried a few times over the last day or so to formulate my questions but ended up staring at a blank screen with glazed over eyes.

I'm trying to take advantage of the power of Pascal instead of just writing around stuff I don't 'get' using simpler but much more of code to get to the needed ends. This time I'd like to get a better grip on the 'fancier stuff'
