Now please dont laugh me into the corner but I have what may be a basic question
So here goes, (for the record I have tried to work this out myself but got lost)
How do I create custom TClass that can take data inputs and then have functions that give results based on those public data inputs. Those data inputs also need to include several arrays of data. the inputs will be mainly integers but there may be some strings
Next question is how do I save that TClass object so I can use it across multiple applications and how do I start it. ie do I create a new "pas file’ and when i save it what do I save it to
So now that I have my TClass how do I include and use it in my application file on say a TForm
Can any one send me a basic template that I can follow
Thank you so much in advance
Thats a lot to ask for. May I suggest that you start with a demo supplied to create a component as the first task. Adding data to a non data aware class is a bit of work too. The easiest thing is to look at the source for say tdbedit.
Once you have registered a component, it’s units will be automatically added to uses clause, when you drop it on a form.
do you have previous programming experience of any type?
I’d say the way to get to where you want is to simplify down to basic ideas … divide and conquer.
It sounds like you want a component that does stuff.
First step would be to create a normal program (form) that does stuff.
Before that, you might even just create a console app that does some of the stuff you want - like eg taking some input and processing it in the way you want.
What form will the input be in, and what form should the output take?
I think you want to create an object with a Property or two.
I would step back a bit though and get everything working on a form in your program. Once that is working move your stuff to an object.
If you want to write a Component then the book ‘More Coding in Delphi’ by Nick Hodges will help.
Reading your original Post I do not believe you want to code components but simply handle some data in objects in your program. If you only want them to exist while the program is running that is easy. If you want the data to hang around after the program closes then you need them to store and retrieve their data via some form of database, file or persistence framework.
Assuming no need for persistence - Here is the interface definition of a fairly complex class.
TIsSensorManager = Class(TObject) // Just to see available sensors
Function SensorSList: TStringList;
Function GetIsTimedEventSensor(ACat: TSensorCategory)
Function SensorRegistered(ASensor: TIsTimedEventSensor): Integer;
Function GetSensorsByCategoryIS(ACategory: TSensorCategory): TSensorArray;
Destructor Destroy; Override;
Function AddIsSensor(ASensor: TIsTimedEventSensor): Integer;
Procedure DropIsSensor(ASensor: TIsTimedEventSensor);
Procedure ActivateAllSensors(AReActivate: Boolean);
Class Function CurrentIsSensorManager: TIsSensorManager;
Class Function SensorCatText(ACat: TSensorCategory): String;
property TextList: String read FTextList;
This defines the “Class” of your imagination
If you then go Control-Shift_C
Coding stubs are created to input you implantation of each procedure and function.
Then in your code you Create an instance of the "Class"
You can create as many instances (Objects) of that class as you like. But do not forget to “Free” each one.
In the case of the TIsSensorManager many objects are created and held within that object using stringlists although generic containers TList is a better way of achieving this.
If you Really want to see the full implantation of that object the code is available in the file IsMobileSensors
If you do need to save the data in the objects I would recommend my OBJECT Dd as a persistence framework