Navigation:  Basic Concepts >

Data Types

Previous pageReturn to chapter overviewNext page

ForeUI supports 4 types of data in user defined properties (custom property): number, string, array and object.

When you create or edit property in the Custom Property View, you will see them in a drop-down list.

choose_property_type

You can also see the same list when editing the Set Global Property action.

prop_type_list_in_action

Number or Evaluable Data

The property in this type can have a number value like “1″, “2.2″ or “2012″, or have an evaluable value that can be evaluated as a number, such as “1+2″, “7*24″, “3-{tmp}” (while {tmp} is a number type property) etc.  So you could do some calculations within this field actually.

String

The property in this type represents a text string.  You can insert any property within the text string, such as “Hello, {name}!” (while {name} is a string type property).  Please notice that when you input the value of string type property, you don’t need to quote the string with quote marks.  If you do need to place a quote mark in your string, please use an anti-slash (\) to escape it.

Array

Array type is introduced since V3.0, and you can use array type property to store a list of values. Each member of the array can be any type of property, so defining multi-dimension array will be possible.  The format of the value will be [member1, member2, member3,...memberN]. Remarks: the array is one-based.  Assume there is an array property {array}, the first member will be {array}[1].  Here are some array examples:

Simple Array: [1, 2, 3]
Two-Dimension Array: [[1,2,3],[4,5,6],[7,8,9]]
String Members: ["Apple","Orange","Banana"]
Object Members: [{"name":"John","age":18,"mobile":"+123456789"},{"name":"Rose","age":17,"mobile":"+987654321"}]

Object

Object type is also available since V3.0, and you can use object type property to store some key-value pairs.  The key must be a string, while the value could be any type of property.  The format of the value will be {key1:value1,key2:value2,key3:value3…}.  Here are some object examples:

Simple Object: {"name":"Mike","age":24,"mobile":"+135792468"}
Nested Objects:   {"user":{"name":"Tom","age":28,"mobile":"+165832234"},"info":{"lastLogin":1340906019605,"message":"Hello World"}}

In order to access the value for given key within the object, you can use this: {object}[key].  Below is an example that will show “Mike” when the page is loaded:

datatype_example

 

Type Changing and Type Casting

Please keep in mind that, the type of property can be changed during the simulation.  If you invoke Set Global Property action to set a predefined property, its data type will be overwritten.  For example: {tmp} was a number type property, now you call Set Global Property action on it and specify the type to “String”, then {tmp} will become a string property after the action is executed.

Also you can cast the property to a different type too. Using a capital letter N/S/A/O at the beginning of the property can declare which data type should the property be cast to.

N{“a”} means casting property “a” to a number

S{“a”} means casting property “a” to a text string

A{“a”} means casting property “a” to an array

O{“a”} means casting property “a” to an object