# Structure

## Block

Represents a block to group statements. A Block element allows the clustering and naming of statements for a better organization of the code.

#### Syntax <a href="#pragma-line-3760" id="pragma-line-3760"></a>

```
Block ( [Name] , Block )
```

#### Parameters <a href="#pragma-line-3766" id="pragma-line-3766"></a>

\-

***Block***\
&#x20;Represents the list of statements.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3777" id="pragma-line-3777"></a>

Void

## Case

Represents a case element for a Switch structure element. If the evaluated expression is found to be TRUE, the code in the following Branch is executed.

#### Syntax <a href="#pragma-line-3786" id="pragma-line-3786"></a>

```
Case ( Expression [, Branch] )
```

#### Parameters <a href="#pragma-line-3792" id="pragma-line-3792"></a>

***Expression***\
&#x20;Condition that is used to determine if the case matches.\
&#x20;Type: Any

***Branch*** (optional)\
&#x20;List of statements which will be executed if the case matches.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3803" id="pragma-line-3803"></a>

Case

## Comment

Void Comment( String Value ) Allows inline comments (has no effect on execution).

#### Syntax <a href="#pragma-line-3786" id="pragma-line-3786"></a>

```
Void Comment(
    String Value
)
```

#### Parameters <a href="#pragma-line-3792" id="pragma-line-3792"></a>

**Value** *(optional)*\
&#x20;The inline comment.\
&#x20;*Type: String*

**Return Type**\
Void

## DoWhile

Takes a condition as input and evaluates it. As long as this condition evaluates to TRUE, the Statements in the loop will be executed.

#### Syntax <a href="#pragma-line-3812" id="pragma-line-3812"></a>

```
DoWhile ( Condition , Loop )
```

#### Parameters <a href="#pragma-line-3818" id="pragma-line-3818"></a>

***Condition***\
&#x20;Condition which is evaluated.\
&#x20;Type: Boolean

***Loop***\
&#x20;List of statements which will be executed if condition is satisfied.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3829" id="pragma-line-3829"></a>

Void

## Error

Represents an error in the script execution. Takes a String as input which will be displayed as error message.

#### Syntax <a href="#pragma-line-3838" id="pragma-line-3838"></a>

```
Error ( Message )
```

#### Parameters <a href="#pragma-line-3844" id="pragma-line-3844"></a>

***Message***\
&#x20;Message which is shown in case of an error.\
&#x20;Type: String

#### Return Type <a href="#pragma-line-3851" id="pragma-line-3851"></a>

Exit

## ForEach

The ForEach loop takes a list of objects identified with ObjectName as input and executes a list of statements for each item in that list individually.

#### Syntax <a href="#pragma-line-3860" id="pragma-line-3860"></a>

```
ForEach ( Objects , ObjectName , Loop )
```

#### Parameters <a href="#pragma-line-3866" id="pragma-line-3866"></a>

***Objects***\
&#x20;List of objects which the operation is performed on.\
&#x20;Type: List\<Object>

***ObjectName***\
&#x20;Variable Name to identify the object in the condition.\
&#x20;Type: String

***Loop***\
&#x20;List of statements which are executed for each object.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3881" id="pragma-line-3881"></a>

Void

## IfThenElse

Takes a condition as input. If the condition evaluates to TRUE, the statements in the Then block will be executed. If the condition evaluates to FALSE, the statements in the Else Blocks will be executed.

#### Syntax <a href="#pragma-line-3890" id="pragma-line-3890"></a>

```
IfThenElse ( Condition , Then [, Else] )
```

#### Parameters <a href="#pragma-line-3896" id="pragma-line-3896"></a>

***Condition***\
&#x20;Condition which is evaluated.\
&#x20;Type: Boolean

***Then***\
&#x20;List of statements executed if the condition is TRUE.\
&#x20;Type: Any

***Else*** (optional)\
&#x20;List of statements executed if the condition is FALSE.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3911" id="pragma-line-3911"></a>

Void

## IfThenElseExpression

Returns the Then value if the Condition evaluates to TRUE; returns the Else value otherwise (aka conditional operator, ternary operator, ternary if, inline if or iif.

#### Syntax

```
Any IfThenElseExpression(
    Boolean Condition,
    params Any Then,
    params Any Else
)
```

#### Parameters

***Condition***\
The condition to check.\
Type Boolean

***Then***\
The value to return if the condition evaluates to TRUE.\
Type Any

***Else***\
The value to return if the condition evaluates to FALSE.\
Type Any

#### Return Type

Any

## Return

Terminates the script and returns the value of the expression as the result.

#### Syntax <a href="#pragma-line-3920" id="pragma-line-3920"></a>

```
Return ( Expression )
```

#### Parameters <a href="#pragma-line-3926" id="pragma-line-3926"></a>

***Expression***\
&#x20;The expression of the value to return.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-3933" id="pragma-line-3933"></a>

Exit

## Switch

Represents a switch structure element. When a matching case branch is empty, then no branch actions are executed.

#### Syntax <a href="#pragma-line-3942" id="pragma-line-3942"></a>

```
Switch ( Expression [, Default] [, Cases] )
```

#### Parameters <a href="#pragma-line-3948" id="pragma-line-3948"></a>

***Expression***\
&#x20;Expression which is used to match.\
&#x20;Type: Any

***Default*** (optional)\
&#x20;Specifies the default case of the switch case expression.\
&#x20;Type: Any

***Cases*** (optional)\
&#x20;A list of cases that are matched against.\
&#x20;Type: List\<Case>

#### Return Type <a href="#pragma-line-3963" id="pragma-line-3963"></a>

Void

## TryCatch

Represents a try-catch structure element.

#### Syntax <a href="#pragma-line-3972" id="pragma-line-3972"></a>

```
TryCatch ( Try , Catch )
```

#### Parameters <a href="#pragma-line-3978" id="pragma-line-3978"></a>

***Try***\
&#x20;List of statements which can throw an exception while executed\
&#x20;Type: Any

***Catch***\
&#x20;List of statements which are executed in case of an error.\
&#x20;Type: Void

#### Return Type <a href="#pragma-line-3989" id="pragma-line-3989"></a>

Void

## TypeOf

Returns the type of a value as a string. Following types are supported: Boolean, Byte, Char, DateTime, Numeric, Double, Float, Guid, Integer, Long, Short, String, and TimeSpan.

#### Syntax

```
TypeOf ( Value )
```

#### Parameters

**Value**\
&#x20;The value to get the type from.\
&#x20;Type: Any

#### Return Type

String

## While

Represents a while-loop structure element. The while structure executes a list of statements while the conditions is TRUE.

#### Syntax <a href="#pragma-line-3998" id="pragma-line-3998"></a>

```
While ( Condition , Loop )
```

#### Parameters <a href="#pragma-line-4004" id="pragma-line-4004"></a>

***Condition***\
&#x20;Condition which is evaluated.\
&#x20;Type: Boolean

***Loop***\
&#x20;List of statements which is executed while the condition is TRUE.\
&#x20;Type: Any

#### Return Type <a href="#pragma-line-4015" id="pragma-line-4015"></a>

Void

## &#x20;<a href="#pragma-line-4020" id="pragma-line-4020"></a>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tivity.one/building-an-application/execution/scripting/functions/structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
