Pushing Podio
Search
ūüďĆ

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 x

Naming your Code

Since there is no concept of a name when passing code from an automation, it is best to have the first line of your code as a comment to be able to differentiate it in your ProcFu stats later. Eg:

// Calculate something
x = [(Variable) foo]
// rest of code ...

It is technically not required to name your code, but in the absence of the first line comment, your stats in ProcFu will use keywords from the start of the code, which will be confusing and if there's a GlobiFlow token there, each execution will create a new stats "object".

The Chrome extension will enforce the first line comment for you.

Returning 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 x

Case 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 = bar

Note 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 - 42

String 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 + 5

The above would return [1,2,3,5]

No Functions

At this time there are no functions. However it would be casually safe to assume that function support will come soon.

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 x

Identical Example:

x=y+z
YIELD x

This 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) [ELSE statement(s)]

or

IF ( expression ) { 
	statement(s) 
[} ELSE { 
		statement(s)]
}

Examples:

IF ( 1 > 0 ) PRINT "1 is greather than 0"
IF ( "foo" <> "bar" ) {
    PRINT "foo is not bar" 
} ELSE {
    PRINT "foo is bar - WTF???"
}

Would output:

1 is greather than 0
foo is not bar

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>42

WHILE 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
done

Exiting 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, just let us know.

ProcFu Scripts

All ProcFu scripts are available as functions in ProcScript. For example:

name = "John"
greeting = HELLO_WORLD(name)
PRINT greeting

NOTE: 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.

(c) 2021 Globi Web Solutions | Join the Discussion in our Podio Workspace.