ProcScript Language Basics
The ProcScript language is targeted to embedded systems so that it can be easily used inside other programs like Citrix Podio Workflow Automations (GlobiFlow).
ProcScript is a simplified version of PHP and borrows some concepts from JavaScript. It is also extremely forgiving.
Comments
Single line comments start with // and multi-line comments can be enclosed in /* and */. Eg
// This is a comment
x = x + 1 //increment xReturning a Value
If you need to return a value to your automation, use the RETURN command. Eg:
// Multiply by 2
x = [(Variable) foo]
x = x * 2
RETURN xCase Insensitive
Keywords are case-insensitive. This means that PRINT "Hello" is exactly the same as print "Hello" (but print "heLLo" is different!).
Untyped Variables
Variables are completely untyped. You can put any value into any variable.
If a variable has no value, it will return a default of NULL
Arrays and Objects
Arrays are just variables, and objects are just arrays. You can use both PHP and JavaScript formatting to create them, eg:
a1 = ["foo"=>"bar", "baz"=>42]
a2 = {foo:"bar", baz:42}
PRINT ( a1 == a2 )
PRINT a1.foo + " = " + a2["foo"]The above would output:
TRUE
bar = barNote that PRINT will not output anything when the code is actually run, but it is extremely useful for debugging as this Editor will show output.
Simplified Operators
Assignment operators like += and ++ are not supported. You need to use long-hand formats, eg:
x = x + 1
y = y - 42String concatenation is done using the + operator like in JavaScript and not the . operator in PHP. Furthermore, the + and - operators can work on different variable types and try to come to the best outcome.
Example:
x = [1,2,3]
return x + 5The above would return [1,2,3,5]
Functions
Functions work the same way as they do in PHP and JavaScript, eg:
PRINT add(2,3)
function add(num1, num2) {
return num1+num2
}Returning Data
In an embedded environment, things like PRINT are not very useful. Usually you want your code to evaluate something and return something else.
To achieve this, you can use the YIELD statement or using RETURN with an expression.
Example:
x=y+z
RETURN xIdentical Example:
x=y+z
YIELD xThis will result in the value of x being returned to the calling program.
IF ... THEN Conditions
The IF THEN statement is the cornerstone of logic. It will evaluate the expression after IF, and execute the code only if the expression was true, and optionally any code after ELSE if the expression was false.
The logic block can be a single line, or on multiple lines, but then must be enclosed in { brackets }.
Syntax:
IF ( expression ) {
statement(s)
}or
IF ( expression ) {
statement(s)
} ELSE {
statement(s)
}FOREACH ... AS ... Loops
Creates a loop iterating over an object or array's keys.
Syntax
FOREACH ( array AS part ) { statement(s) }
or
FOREACH ( array AS key => part ) { statement(s) }
Example
obj = {foo:"bar",baz:42}
FOREACH ( obj AS part ) {
PRINT part
}
FOREACH ( obj AS key => part ) {
PRINT key+">"+part
}Result:
bar
42
foo>bar
baz>42WHILE Loops
Creates a loop while a condition expression evaluates to true
Syntax
WHILE ( condition ) {
statements(s)
}Example
i=1
WHILE ( true ) {
i = i + 1
PRINT "i is "+i
IF i > 5 THEN BREAK
}
PRINT "done"
Result:
i is 2
i is 3
i is 4
doneExiting Loops
You can BREAK out of loops and CONTINUE execution of the next loop iteration with those same keywords. Very similar to PHP and Javascript.
PHP Functions
Many standard PHP functions are available. In fact, every PHP function available in GlobiFlow is available in ProcScript, plus more.
If you need additional commands and functions, please submit a support ticket with details and reasons for the request.
ProcFu Functions API
All ProcFu Functions are available as native commands in ProcScript. For example:
name = "John"
greeting = HELLO_WORLD(name)
PRINT greetingNOTE: Conversion to and from JSON is done automatically since ProcFu scripts all require text inputs and return text outputs. You can safely pass them arrays, and will get arrays and objects back.
Similarly, if you RETURN arrays or objects to the calling system, they will be converted to JSON.
More Help
At any time in the editor, you can press F1 while on a keyword and the help for that keyword will be shown.