Introduction | Your first interface | Building a model | Advanced features | Resources

3.2 Adding model properties

In this step, you'll see how to add properties to a model so that they can be accessed by the Interface Builder.

Before you start to use the Model Wizard, you must have a good idea of what the model you're writing is going to do. What are the inputs and outputs, and what operations are going to be carried out on them? In particular, you need to decide which of the model variables must be accessed by the interface builder - these are the properties.

The Ohm's Law model you're building has three variables that you want the user to be able to access: resistance, voltage and current. So you need three model properties.

Let's start with resistance:

  • The property name is the name as it will appear in the Interface Builder (i.e. Resistance).
  • The property type describes whether the property is, for instance, input or output (in practice, you will almost always use dual instead of input as this gives the interface designer more flexibility).
  • The variable name is the property name as it will appear in the model (i.e. R).
  • The field type is the type of variable - primitive, string, or object. (i.e. integer).
  • Dimensions determines whether the variable is an array and its size (a value of 0 means it's not an array).
  • The update method is the name of a method called when the property value is updated at the user interface (i.e. changeR). Not all properties need have update methods.
  • The link property allows you to link a variable with another object. You will not be using it in this example.

When the information for the resistance property has all been added, the Model Wizard will look something like this:

Click Add to add the property. If you want to amend a property, select it in the selection box below, make your amendments and click Update.

Add resistance to the Model Wizard. Then go on to add voltage (variable name V, double, input, changeV) and current (name I, double, dual, no update method).

When you have added all three variables, you are ready to move on to the next step - adding actions.