---
title: "Data types"
canonical: "https://docs.cuesystem.com/space/CVCHELP/495058958/Data%20types"
format: markdown
---
> Macro (toc)

---

# Boolean

Boolean variables can only be **True** or **False**. Use the keywords True and False to assign one of the two states to Boolean variables. If a Boolean variable is declared without InitExpression it is automatically initialized to the default value **False**. 

#### Syntax 

```visualbasic
[Accessibility]Var VariableName As Boolean [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Example 

```visualbasic
Var DoorIsClosed As Boolean // DoorIsClosed is automatically initialized to False 
Var LightIsOff As Boolean := True WithAttributes { Info:= "if variable is true light is off" }
```

# Byte

It is an integral number without a sign ranging in value from **0** to **255**. If the Byte variable is declared without InitExpression it is automatically initialized to default value **0**. 

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Byte [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Example 

```visualbasic
Var Day As Byte // Day is automatically initialized to 0 
Var Month As Byte := 1
```

# Long

It is an integral number with a sign in case of a negative number ranging in value from **-2147483648** to **2147483647**. If a Long variable is declared without InitExpression it is automatically initialized to default value **0**. 

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Long [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Example 

```visualbasic
Var Count As Long 
Var Index As Long := 600000
```

# Double

It is a floating point number with a sign in case of a negative number. Full number of decimal places, if the number is not integral ranging in value from **1.7E-308** to **1.7E+308**. If a Double variable is declared without InitExpression it is automatically initialized to the default value of **0.0**. 

A floating point number can be entered in the exponential form as well.

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Double [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Example 

```visualbasic
Var Width As Double // Width is automatically initialized to 0.0 
Var Length As Double := 120.5
Var SomeValue As Double := 1E-5     /* =  0.00001 */
Var SomeValue1 As Double := 25E-5     /* =  0.00025 */
Var SomeValue2 As Double := 25e4     /* =  250000.0 */
Var SomeValue3 As Double := 13.1e+4     /* =  131000.0 */
Var SomeValue4 As Double := 13.1e-4     /* =  0.00131 */
Var SomeValue5 As Double := -13.1e+4     /* =  -131000.0 */
Var SomeValue6 As Double := -13.1e-4     /* =  -0.00131 */
```

# Time

Time represents absolute time (e.g. October 22, 2009 14:30) or a time interval (e.g. 2 hours and 10 minutes). If the Time variable is declared without InitExpression it is automatically initialized to default value **:0**. 

The time interval is in the format "days:hours:minutes:seconds.microseconds". If the interval is shorter than one day, days need not be entered. If the interval is shorter than one hour, hours need not be entered. If the interval is shorter than one minute, minutes need not be entered. 

<u>[See time constant values](/wiki/spaces/CVCHELP/pages/498532601/Constant+values#TimeConstantValue)</u> 

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Time [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Absolute time 

```visualbasic
Var StartTime As Time := #03/14/2009 12:35:05# 
Var EndTime As Time := #04/14/2009 18:55:05# 
Var Time1 As Time := #03/14/2009 12:35:05.1# 
Var Time2 As Time := #03/14/2009 12:35:05.12# 
Var Time3 As Time := #03/14/2009 12:35:05.123456#
```

#### Time interval 

```visualbasic
Var TimeHours As Time := 3:4:15 
Var TimeMinutes As Time := 2:20 
Var TimeSeconds As Time := :4 
Var Time1 As Time := :4.1 
Var Time2 As Time := :4.12 
Var Time3 As Time := :4.123456
```

# Char

Char variable contains one character of Text. If the Char variable is declared without InitExpression it is automatically initialized to default value **0**. 

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Char [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Example 

```visualbasic
Var First As Char := 'A'
```

#### Example 

```visualbasic
Var Name As Text[30] := "Hello" 
Var First As Char 

First := Name[1] // First := 'H'
```

# Text

Text variables consist of Chars. The Text is always indexed from one. 

Note: When a variable length is changed by direct access to variable's [/wiki/spaces/CVCHELP/pages/495058958/Data+types#Char](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Char), it must be set by function <u>[SetTextActualLength](/wiki/spaces/CVCHELP/pages/512327836/Text#SetTextActualLength)</u>. 

If the Text variable is declared without InitText it is automatically initialized to the default text value "". 


**Note**: Character `"` (quotation mark) could be entered to Text constant by `\"` and character \ (backslash) could be entered by `\\`

**Note: **Every character can be entered as four hexadecimal number characters preceded by a sign \. This is suitable mainly for the non-printable character.

Example: &S"\000A" is the Line feed. 


| **Escape sequence** | **Character represented** |
| --- | --- |
| `\"` | quotation mark |
| `\\` | backslash |
| `\hhhh` | A character whose numeric value is given by hhhh and is interpreted as a hexadecimal number. |


Note: Maximum length of the Text variable is limited. The limit is on the page <u>[System limits](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585)</u>. 

#### The maximum length of a Text is defined 

The InitText is optional. Into the Text are stored at the most characters from the InitText as the Text declared length is. 

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Text[Length] [:= "InitText"] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Example 

```visualbasic
Var Message As Text[200] 
Var Status As Text[100] := "Reading" 

// maximum length is 100, 7 characters are used currently 
Var DayOfWeek As Text[10] := "It's Monday today" 

// the maximum length of 10 is too short to store the whole InitText "It's Monday today" 
// so only "It's Monday" is stored in the DayOfWeek Text 
Var TwoLines As Text [100] := "First line\000ASecond line"
```

#### **Initial Text is defined** 

The maximum length of the Text is the same as the length of the InitText. 

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Text := "InitText" [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Example 

```visualbasic
// Text is initialized to "Game is over!" (13 characters), 
// so the maximum length of a Text is 13 
Var Warning As Text := "Game is over!"
```

#### It is equivalent to the example 

```visualbasic
Var Warning As Text[13] := "Game is over!"
```

#### It is equivalent to the example 

```visualbasic
Var Warning As Text[13] 
Warning := "Game is over!"
```

# ByteString

ByteString variables consist of Bytes. The ByteString is always indexed from one. 

If the ByteString variable is declared without InitByteString it is automatically initialized to default ByteString value &S"". 

Note: When a variable length is changed by direct access to the variable's <u>Bytes</u>, it must be set by the function <u>[SetByteStringActualLength](/wiki/spaces/CVCHELP/pages/510591253/ByteString#SetByteStringActualLength)</u>. 



**Note**: Character `"` (quotation mark) could be entered to ByteString constant by `\"` and character \ (backslash) could be entered by `\\`

**Note: **Every character can be entered as two hexadecimal number characters preceded by a sign \. This is suitable mainly for the non-printable character.

Example: &S"\0A" is the Line feed. 


| **Escape sequence** | **Character represented** |
| --- | --- |
| `\"` | quotation mark |
| `\\` | backslash |
| `\hh` | A byte whose numerical value is given by *hh* interpreted as a hexadecimal number |


Note: Maximum length of the ByteString variable is limited. The limit is on the page <u>[System limits](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/510787585)</u>. 

#### The maximum length of a ByteString is defined 

The InitByteString is optional. Into the ByteString are stored at the most characters from the InitByteString as the ByteString declared length is. 

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As ByteString[Length] [:= &S"InitByteString"] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

####  Example 

```visualbasic
Var Status As ByteString[100] := &S"123000\ff" 
Var TwoLines As ByteString[100] :=  &S"First line\0ASecond line"
```

#### Initial ByteString is defined 

The maximum length of the ByteString is the same as the length of the InitByteString. 

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As ByteString := &S"InitByteString"
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

####  Example 

```visualbasic
Var Warning As ByteString := &S"123000\ff"
```

# Anything

In a variable of this type can be stored an address of any other type (e.g. AddressOf Long, AddressOf Text, ...). To operate the variable Anything type, it must be assigned to a real data type (e.g. Long, Text, ...). See example. 

#### Syntax 

```visualbasic
[Accessibility] Var VariableName As Anything [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Example 

```visualbasic
Var AnythingVar As Anything 
Var TextVar As Text[100] 

AnythingVar := "Hello!" // Address of Text "Hello!" is assigned to variable AnythingVar 
TextVar := AnythingVar  // Text value from the address which is in AnythingVar is assigned to  
                        // text variable TextVar 
DebugPrint(TextVar)
```

It prints to the debug window: 

```visualbasic
Hello!
```

# Array

Arrays allow you to refer to a series of variables by the same name and to use a number (an index) to tell them apart. This helps you create smaller and simpler code in many situations, because you can set up loops that deal efficiently with any number of cases by using the index number. 

All the elements in an array have the same data type. The array is always indexed from one. 

InitExpression initializes all items of an array. The InitExpression can be a number, Text/ByteString, Char, Boolean, or Time. The more dimensional array can be initialized as well. See examples. 

An array on the right side ":=" operator must be the same type and the same length and defined in the same controller as an array on the right side. 

Elements in an array can be explicitly initialized to specific values when it is declared by enclosing them in square brackets []. The number of values cannot be greater than the number of elements in the array. If declared with less, the remaining elements are set to their default values.  

#### Syntax 

```visualbasic
[Accessibility] Var VariableName[NumberOfItems1 [, NumberOfItems2 [, ... [, NumberOfItemsN]]]] As ItemsType [:= InitExpression] [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info 

|  |  |  |
| --- | --- | --- |
| Value type | Meaning | Example |
| Text | Text which will be visible in a tooltip window for this property. | Info := "Any text " |

#### Example: One-dimensional array of a numerical type 

```visualbasic
Var A[8] As Long
```

#### Example: Two-dimensional array of a numerical type 

```visualbasic
// array has 15 (5 x 3) items 
Var B[5, 3] As Long
```

#### Example: One-dimensional array of a Text type* *

```visualbasic
// array contains five Texts, 
// each of them contains a maximum of 50 characters 
Var S[5] as Text[50]
```

#### Example of initialization one-dimensional array 

```visualbasic
// all ten elements are initialized to values declared square bracket [] 
Var A[10] As Long := [10,20,30,40,50,60,70,80,90,100] 

// value in element A[1] is 10 
// value in element A[2] is 20 
// value in element A[3] is 30 
// value in element A[4] is 40 
// value in element A[5] is 50 
// value in element A[6] is 60 
// value in element A[7] is 70 
// value in element A[8] is 80 
// value in element A[9] is 90 
// value in element A[10] is 100 

// first five elements are initialized to values declared in square  
// bracket, five remaining elements are initialized to zero value 
Var Ax[10] As Long := [3,7,34,23,65] 

// value in element Ax[1] is 3 
// value in element Ax[2] is 7 
// value in element Ax[3] is 34 
// value in element Ax[4] is 23 
// value in element Ax[5] is 65 
// value in elements Ax[6], Ax[7], Ax[8], Ax[9], Ax[10] is 0 

// initialization array of Text type 
Var TArray[2] As Text[15] := ["FirstElement", "SecondElement"] 

// all items of array B are set to 4 
Var B[10] As Long := 4 

// all items of array C are set to the same values as array A 
// array C must be the same type as array A 
Var C[10] As Long := A 

// all items of array A are set to 5 
A := 5
```

#### Example of initialization two-dimensional array of a numerical type 

```visualbasic
// all items of array A are set to 40 
Var A[5, 3] As Long := 40 

// all elements in the array are initialized to declared values 
Var XX[2,2] As Long := [[30,60],[100,200]] 

// value in element xx[1,1] is 30 
// value in element xx[1,2] is 60 
// value in element xx[2,1] is 100 
// value in element xx[2,2] is 200
```

#### Example of assignment 

```visualbasic
Var A_Long[20] As Long 
Var A_Byte[20] As Byte 

A_Long := A_Byte // error, not the same type
```

#### Example of assignment 

```visualbasic
Var A1_20[20] As Long 
Var A2_20[20] As Long 
Var A3_60[60] As Long 

A1_20 := A2_20 // OK, the same length 
A1_20 := A3_60 // error, not the same length
```

# Enum

An enumeration is a listing of enumeration items and optionally their values. The enumeration type can be declared only at the <u>[programming module](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509083842)</u> level. 

#### Syntax of an Enum data type declaration 

```visualbasic
Enum TypeName Item1 [:= ConstExpression] [, Item2 [:= ConstExpression]] [, ItemN [:= ConstExpression]] End Enum
```

#### Example: Declarations the Enum type and definition of an Enum variable 

```visualbasic
// enum type 
Enum BASIC_COLOURS 
  White, 
  Black, 
  Red, 
  Green, 
  Blue, 
  Yellow 
End Enum 

// enum variable 
Var WindowColour As BASIC_COLOURS := BASIC_COLOURS.White
```

#### Example: Declarations the Enum type and definition of an Enum variable 

```visualbasic
// enum type 
Enum InputStatus 
  Success := 0, 
  Warning := 1, 
  CriticalError := 5 
End Enum 

// enum variable 
Var DetectorInput As InputStatus := Success
```

# Structure

A structure is a data type that contains more variables in one object. The structure data type is defined by its StructureName. A structure variable is declared via the StructureName (not by the keyword structure). The structure type can be declared only at the <u>[programming module](https://cue.atlassian.net/wiki/spaces/CVCHELP/pages/509083842)</u> level. 

An instance of structure can be explicitly initialized to specific values when it is declared by enclosing in braces {}. The number of values cannot be greater than the number of items in the structure. If declared with less, the remaining items are set to their default values.  

If you need to share data between the graphics class and device driver, it is necessary to declare an identical structure in the class module and driver. Variables of these structures can be assigned to each other. 

#### Syntax 

```visualbasic
[Accessibility] Structure StructureName  
  [Variable declarations]
End Structure
```

#### Example 

```visualbasic
// structure type 
Structure SPoint 
  Var x As Long 
  Var y As Long 
  Var Colour As Long 
End Structure 

// structure variables 
Var Point1 As SPoint 
Var Point2 As SPoint
```

#### Example of an initialization structure instance 

```visualbasic
Var Point2 As SPoint := {3,5,56} 

// value in Point2.x is 3 
// value in Point2.y is 5 
// value in Point2.Colour is 56
```

#### Example of initialization array of structures 

```visualbasic
Var PointsArray[3] As SPoint := [{3,5,56},{30,50,200}] 

// value in PointsArray[1].x is 3 
// value in PointsArray[1].y is 5 
// value in PointsArray[1].Colour is 56 
// value in PointsArray[2].x is 30 
// value in PointsArray[2].y is 50 
// value in PointsArray[2].Colour is 200 
// value in PointsArray[3].x is 0 
// value in PointsArray[3].y is 0 
// value in PointsArray[3].Colour is 0
```