Converting VBScript Function calls to IronPython Syntax

When used for scripting, IronPython function names are always followed by parentheses.

So:

The parentheses change is the only one to keep in mind when converting VBScript function calls syntax to IronPython.

Return Values

VBscript return values are sometimes assigned via the Set declaration. IronPython return values are simple assignment (See: Iron Python Mini Cookbook).

Primitive Method Arguments

Replace each VBScript primitive with an equivalent IronPython primitive.

Boolean values in IronPython have their first letter capitalized (True instead of true and False instead of false).

For arrays, the recommended approach is to simply replace a VBScript array with a Python array. The mapping is simple:

Named Array Arguments

Formatting helps readability immensely but is not required.

All that must be done is:

Named Array Values with All Key Value Pairs

While it is generally not allowed to replace arrays and nested arrays with Python dictionaries, in the case where the named array consists entirely of key value pairs, you can use a dictionary and avoid typing the trailing := symbols after the keys. This further aids readability of the script.

Named Arrays with Nested Named Arrays

[ "NAME:name",

"key1:=" , 1,

"key2:=" , 2,

["NAME:name2", "R:=", 255]

]

Sample Script: Named array with nested named array in array syntax

The above named array with a nested named array (after conversion to IronPython as named array) can be converted to a dictionary as well. The dictionary can take any of the following forms

{ "NAME" : "name",

"key1" : 1,

"key2" : 2,

"name2" : ["NAME:name2", "R:=", 255]

}

Sample Script: Named array with nested named array as mixed dictionary + array

{ "NAME" : "name",

"key1" : 1,

"key2" : 2,

"name2" : {"R" : 255}

}

Sample Script: Named array with nested named array in all dictionary syntax

{ "NAME" : "name",

"key1" : 1,

"key2" : 2,

"name2" : {

"NAME" : "name2",

"R" : 255

}

}

Function Blocks

Function blocks in VBScript argument syntax are represented as arrays without the "NAME:.." field. However, functions are always introduced by a key in a parent structure. Function blocks can therefore never exist as a top-level argument. They are only found as the value pairs inside a named array or inside another function block.

Important:

Function blocks and their items cannot be converted to dictionaries even though they might be composed entirely of key value pairs.

The reason for this is the need to main the user-entered order. Every item in a function block is expect to be transmitted to the script method in exactly the same order as typed out and this is impossible to achieve when a dictionary is used (as the keys get reordered according to the dictionary's internal tree/key sorting scheme).

When you see a function block, simply replace the Array( ) delimiters with python array delimiters [ ]