Scripting and Syntax
DGLux5 script (DG Script) is a small scripting language that looks like JavaScript. Use it when a calculation or a piece of logic is easier to write as code than to build from dataflow blocks.
Where You Can Use Script
- The Script block runs a script and puts the result on its output property.
- Table blocks run a short script for every row: Filter (condition), Column Mapping, Edit Rows and Remove Rows. See Scripts in table blocks.
- Binding paths use the same
@names as scripts. See Page Model. - To run real browser JavaScript, use the JavaScript block instead.
A first script, in a Script block:
var total = 0; for (var i = 1; i <= 10; i++) { total += i; } print("done"); return total; // the block's output becomes 55
Documentation
| Page | Contents |
|---|---|
| Language Basics | Syntax, statements, functions, types and operators, and how DG Script differs from JavaScript |
| Page Model | Reading and setting component values with @, creating bindings from script, and reusing scripts |
| Debugging | print, printConsole, error messages and profiling |
| Strings and Regular Expressions | String methods, regular expressions, encoding and hashing |
| Numbers and Math | Number conversion, numberFormat patterns, Math functions and constants |
| Dates and Times | DateTime, dateFormat, dateParse, date strings and format patterns |
| Lists and Maps | List methods, sorting, maps and for…in |
| JSON and XML | Parsing and creating JSON and XML |
| Tables | Reading and building DGLux5 tables, and scripts in table blocks |
| Model Functions | Creating, saving, moving and removing components and blocks from script |
| HTTP Requests and Browser Utilities | fetchHttpUrl, promises, blob URLs and calling browser JavaScript |
| Examples | Longer worked examples |
See also:
- JS Widget Components: turn third-party JavaScript libraries into DGLux5 components (dglux5_js_lib on GitHub)
Moved Sections
The sections that used to be on this page have moved:
- Debugging: Debugging
- Number format patterns: Number Format Patterns
- Date format patterns: Date Format Patterns
- Supported date strings: Date Strings
- Lists: Lists and Maps
- Lat-long operations and custom easing functions: Examples