Building Lifecycle Applications for v4.7

The DocScript language has the following elements:

# Variables

Format

{variablename}

The variable name can be any character, except ‘[‘ and ‘]’.

# Declaration

Variables are declared as needed. To declare a variable just write the variable name in the script. Examples:

{a} = 2 {b} = ‘Hello World’ {c} = {a}

# Types

A variable can store an integer, decimal or string value. The variables type can change during the script. Typing is not enforced by the language. Booleans are stored as an integer, where 1 is true and any other value is false.

**Examples:**

An integer variable: {myVariable} = 3

A decimal variable: {myVariable} = 3.5

A string value: {myVariable} = ‘Hello World’

# Variable Arrays

A variable can also be an element of an array. If a variable is an element of an array it is declared as:

{arrayname[elementnumber]}

Arrays always start at an element number of 0. The length of an array is always one larger than the largest element number defined in that point in the script. For example:

{a[0]} = 3 //At this point the array length is 1 {a[1]} = 2 //At this point the array length is 2 {a[100]} = 3 //At this point the array length is 101.

The current array length is stored in the variable {arrayname}. For example,

{a[0]} = 3 //At this point the array length is 1. So {a} would have the value of 1. {a[1]} = 2 //At this point the array length is 2. So {a} would have the value of 2. {a[100]} = 3 //At this point the array length is 101. So {a} would have the value of 101.

# Arithmetic Operators

The scripting language has the following arithmetic operators:

Plus: +

Minus: -

Divide: /

Multiply: *

Equate: =

Operations are always performed from right to left. Brackets must be used to control the order of operations. If a set of operations is inside a bracket the operations will be performed from right to left inside that bracket.

**Examples:**

{a} = 1 {b} = {a}*100 {c} = 50 {d} = 100/5/2 //The result is 40. {e} = (100/5)/2 //The result is 10.

All arithmetic operations are decimal based. There is no rounding or truncation of decimals.

# Boolean Operators

The scripting language has the following logical Boolean operators:

And: and

Or: or

not: not

Operations are always performed from right to left. Brackets must be used to control the order of operations. If a set of operations is inside a bracket the operations will be performed from right to left inside that bracket.

**Examples:**

{a} = 1 {b} = 0 {c} = ({a} and {b}) //result is 0 {d} = ({a} or {b}) //result is 1.

Booleans are stored as an integer, where 1 is true and any other value is false.

# Conditional Operators

The scripting language has the following conditional operators:

Is equal to: ==

Is not equal to: not=

Is greater than: >

Is less than: >

Is greater than or equal to: >=

Is less than or equal to: <=

Operations are always performed from right to left. Brackets must be used to control the order of operations. If a set of operations is inside a bracket the operations will be performed from right to left inside that bracket.

**Examples:**

{a} = 10 {b} = 4 {c} = ({a} > {b}) //result is 1 {d} = ({a} < {b}) //result is 0.

Booleans are stored as an integer, where 1 is true and any other value is false.

All conditional operators will work on Boolean, integer and decimal values. ‘==’ and ‘not=’ will work of strings as well. ‘>’,’<’,’>=’,’<=’ will not work on strings.

# String Operators

The scripting language has the following string operators:

Equate: =

Combine: &

**Examples:**

{a} = ‘hello’ {b} = ‘ world’ {c} = {a} & {b} //result is ‘hello world’

# Conditional Statements

The scripting language has the following conditional execution constructs:

If statement: if (conditional) true code end If, Else Statement: if (conditional) true code else false code end If, ElseIf Statement: if (conditiona1l) conditiona1l true code elseif(conditional2) conditional2 true code end If, ElseIf, Else Statement: if (conditiona1l) conditiona1l true code elseif(conditional2) conditional2 true code else all false code end

Any number of elseif statements can be used. All conditional statements must be inside brackets. Example:

{a} = 2

{b} = ‘dog’

{c} = 10

if ({a} > {c}) {z}=1 elseif ({b} == ‘cat’) {z}=2 elseif (({c} == 5) or ({a}==2)) {z}=3 else {z}=4 end //The result would be 3.

--

# Loop Statements

The DocuNECT scripting language has a while loop statement.

while(break out conditional statement)

code

end

**Example:**

{i}=0 while({i} < 20) i = i +1 end

# Function Calls

Format

[classname.functionname](param1,param2,…,paramN)

Parameters can be variables, strings, integers, decimals, expressions, or function calls.

Capture Lifecycle DocScript Functions

**Examples:**

[PDF.SetFileName](‘c:\\temp\\test.pdf’) {pagecount} = [PDF.GetNumPages]() {i} = 0 while ({i} < {pagecount}) {pagetext} = [PDF.GetSinglePage]({i}) //Do some stuff with the pagetext end [PDF.Close]()

# Interpreter Statements

The scripting language supports the following interpreter statements:

Line Comment: // - All text after this, on the line are ignored by the interpreter.

Line Combine/Split: _ - If at the end of a line will join with the line below before interpreting.

**Example:**

{a} = 2 + 3 + _ //Line split 4 + 6 //same as {a} = 2+3+4+6

# Logging

There are two types of logging available:

**Example**

[DocuNECT.Log]('logmessage') //This places the logmessage in the audit log. [DocuNECT.LogNote]('logmessage') //The LifecycleCapture has standard email notification functionality as part of the definition. Any messages added to the LogNote will be added to this email.