Mediacentral | Asset Management Swodl Reference, Created 9/20/2020
Total Page:16
File Type:pdf, Size:1020Kb
MediaCentral® | Asset Management SWoDL Reference Release 2020.9 Contents Using This Reference ....................................................................... 6 Symbols and Conventions .......................................................................................... 6 If You Need Help ......................................................................................................... 7 Avid Training Services ................................................................................................ 7 1 Introduction ....................................................................................... 8 2 Basic Language Elements ................................................................ 9 Command Separator, Identifiers ................................................................................. 9 Comments ................................................................................................................. 10 Status Definitions ...................................................................................................... 10 Literals ....................................................................................................................... 11 String Literals ....................................................................................................... 11 Integer Literals ..................................................................................................... 12 Floating-Point Literals .......................................................................................... 12 Boolean Literals ................................................................................................... 12 Variables and Constants ........................................................................................... 13 Variable Declaration ............................................................................................. 14 Assigning a Value to a Variable ........................................................................... 15 Constants ............................................................................................................. 16 System Variables ................................................................................................. 16 Structs and Arrays ..................................................................................................... 19 Structs .................................................................................................................. 19 Arrays ................................................................................................................... 22 Combining Structs and Arrays ............................................................................. 24 Using Arrays and Structs to Parse XML Documents ........................................... 26 Expressions ............................................................................................................... 29 Operators ............................................................................................................. 29 Type Considerations ............................................................................................ 30 Cast Operators ..................................................................................................... 31 Pitfall: Variables May Change Operation Type .................................................... 31 Command Blocks ...................................................................................................... 32 Labels, Goto, Gosub, and Return ............................................................................. 33 Labels and Goto ................................................................................................... 33 Gosub and Return ................................................................................................ 33 Functions ................................................................................................................... 33 Declaration ........................................................................................................... 34 Calling a Function ................................................................................................ 34 Input Parameters ................................................................................................. 35 Scope ................................................................................................................... 36 Include ....................................................................................................................... 36 Exit ............................................................................................................................ 38 Error .......................................................................................................................... 38 Delay ......................................................................................................................... 38 Suspend .................................................................................................................... 38 Try-catch, Throw, and Assert .................................................................................... 39 Conditional Command: If – Then – Else ................................................................... 40 Loops ......................................................................................................................... 41 While Loop ........................................................................................................... 41 Do-while Loop ...................................................................................................... 41 Retry-while Loop .................................................................................................. 41 3 Built-in Functions ............................................................................ 43 String Handling .......................................................................................................... 43 String Comparison: compare ............................................................................... 44 Extracting Part of a String: substr ........................................................................ 44 Length of a String: length ..................................................................................... 45 Find a Substring in a String: find .......................................................................... 45 Find Last Occurrence of a Substring: findreverse ............................................... 45 Trim a String: trim................................................................................................. 46 Replace Substrings: replace ................................................................................ 46 Converting a String to Lowercase: str_lower ....................................................... 46 Converting a String to Uppercase: str_upper ...................................................... 46 XML Functions .......................................................................................................... 46 XML Encoding and Decoding: xmlencode and xmldecode ................................. 47 Parsing XML Documents ..................................................................................... 48 Creating XML Documents .................................................................................... 59 Array Functions ......................................................................................................... 66 Aggregating Elements: array_aggregate ............................................................. 66 Checking a Condition on all Elements: array_all ................................................. 67 Checking if any Element Fulfills a Condition: array_any...................................... 68 Transforming an Array: array_select.................................................................... 69 Filtering Elements with a Condition: array_where ............................................... 70 JSON Functions ........................................................................................................ 71 Converting JSON Documents to SWoDL Datatypes ........................................... 72 Converting a Complex SWoDL Type to a JSON Document ................................ 72 Parsing JSON Documents ................................................................................... 73 Creating JSON Documents .................................................................................. 78 Regular Expressions ................................................................................................. 83 Regular Expression Match: regex_ismatch ......................................................... 83 Finding Regular Expression Matches: regex_find ............................................... 84 Replacing Using Regular Expressions: regex_replace ....................................... 84 Defining Match Options ........................................................................................ 86 URI Handling ............................................................................................................. 86 Converting Windows-Style Paths and URIs ........................................................ 86 Creating URIs ......................................................................................................