Variable data types

From webCoRE Wiki - Web-enabled Community's own Rule Engine
Revision as of 01:41, 26 March 2017 by ady624 (talk | contribs)
Jump to: navigation, search
Share on FacebookShare on TwitterShare on Google+Share on LinkedInShare on DiggShare on deliciousShare on redditShare on StumbleUpon

webCoRE supports several variable data types.

Dynamic

Dynamic variables are also known as loose-typed variables. They don't have a set type and can therefore contain any kind of data, from numbers, to strings, to booleans, etc. It is strongly recommended to use a strong-typed variable instead when the values you are planning on storing are of a certain type.

String

String variables can contain any text/number/boolean values represented as a string, for example: "abc123". Note: storing numbers in string variables may lead to undesired results if you plan on comparing values. As strings, "100"<code> is smaller than <code>"50" because comparisons are made using character codes rather than overall values. Since 1 is before 5 in the alphabet, "100" is smaller than "50".

Boolean

Booleans are simple types that can contain one of two values: false or true. When converted to a string, these become "false" and "true". When converted to a number, these become 0 and 1

Number (Integer)

An integer variable can only store whole numbers, for example: 1 or 3983. If you attempt to store a decimal value into an integer variable, the decimal digits are simply dropped (floor).

Number (Decimal)

A decimal variable can contain rational numbers in the decimal form, for example 6.3 or 100.18 or 209.292929. It can also contain whole number values.

Date and Time

A variable of date and time represents a single point in time representing both date and time, for example 8/7/1980 08:39:29 AM.

Date

A variable of date represents a single day, for example 8/7/1980.

Date and Time

A variable of time represents a single point in time that can happen each day, for example 08:39:29 AM.

Device

Device variables can store device handlers such as Kitchen Light. What's special about this type is that it can contain one or more devices (array).