Last modified on 2008-06-05 10:49:13
Classes
Charta contains a lot of basic classes like Text, Integer32, Float64, that you need in any programming language. It also contains some Charta specific classes, like an Output item or a Day of the week.
And then there are the classes you create yourself. In the demo Person and Project are an example of that.
In order to be able to add informtion to a task we will now show you how to create a new class Note
Creating a custom class- Navigate to the explorer and expand the Classes node by pressing Right
- Press Enter
- Select a row and press Ctrl+Insert
- Press Enter
- Type "Note" in the name field
- Select the members field with Windwos+Down and press Insert
- Type "High priority" in the name field of the member and type "boolean" in the type field
- Select the row and press Ctrl+Insert
- Type "Backup" in the name field and select Person as the type
- Select the auto-create field and press Spacebar
- As an excercise add a member of type Note to the Weekly task class
This will show you a table with the classes defined for the demo.
A new class is created at the bottom of the table.
This opens a new tab in the control vault with the fields to define the class.
This adds a row to the members table so that you can define what a note consists of.
When typing in the type field a suggestion is shown. If you press Enter you select that suggested type. If you press Ctrl+Spacebar you will get more suggestions.
This adds another member.
A checkbox appears in the auto-create column. Auto-create means that when an object of your class is created, an object of you member will be created automatically. If the auto-create option is defined by default for the type (like boolean) the checkbox won't appear.
This will set the auto-create option to true.
You have now added your first class.
This should result in
We now have created a new class, and we have used it as a member of another class. But if we create objects of the classes, how do we set the references? The next example will tell you that. We will show you how to reference a Note object from a Weekly task object.
Lessons learned
- Adding classes to your application
- Setting the members of a class
- Using the auto-create option
