RexxJS Reference Documentation
A comprehensive reference guide to all RexxJS features, organized by category.
Execution Mode Overview
RexxJS supports three distinct execution modes, each designed for different use cases and control architectures:
1. Autonomous Web Mode
Direct browser execution where the RexxJS interpreter runs independently within a single web context. The script controls its own execution flow with no external orchestration. Ideal for interaction with standalone web applications, white-box browser automation, and client-side scripting.
2. Controlled Web Mode
Browser execution using a Director/Worker architecture with two iframes communicating via postMessage. An external director orchestrates execution, providing real-time control (pause/resume/abort), progress monitoring, and distributed workflow coordination. Designed for complex multi-step processes requiring external supervision.
3. Command-line Mode
Execution in Node.js environments (desktop, server, docker-style container or VM) with full file system access but no web/DOM capability. While a programming language attempting to use instead of bash will lead to longer scripts.
Detailed documentation for each mode is provided in the sections below and in dedicated function references.
Core Language Features
๐ Basic Syntax
- Variable assignment and management
- Function calls and parameters
- Pipe operator (
|>) for function chaining - Mathematical expressions with operator precedence
- String concatenation (
||) vs arithmetic addition (+) - Comments and code structure
- String interpolation
๐ฏ Control Flow
- IF/ELSE/ENDIF statements
- Complete comparison operators:
=,==,\=,!=,<>,ยฌ=,><,>,<,>=,<= - DO/END loops (range, step, while, repeat)
- SELECT/WHEN/OTHERWISE branching
- SIGNAL statement for jumps
๐ง Advanced Statements
- NUMERIC statement - precision control
- PARSE statement - string parsing
- Stack operations (PUSH/PULL/QUEUE)
- Subroutines (CALL/RETURN)
- TRACE statement - debugging
- Program structure and flow
Built-in Functions
๐ String Functions
- Basic string operations (UPPER, LOWER, LENGTH, etc.)
- Advanced string processing with regex
- String validation and testing
- Text manipulation and formatting
๐งฎ Math Functions
- Basic arithmetic (ABS, MAX, MIN)
- Advanced mathematical functions
- Statistical operations
- Geometry and trigonometry
๐ Array Functions
- Array creation and manipulation
- Array searching and sorting
- Mathematical operations on arrays
- Data processing and analysis
๐๏ธ Date/Time Functions
- Current date and time retrieval
- Date component extraction and parsing
- Date format conversion and validation
- Time-based calculations and workflows
๐ JSON Functions
- JSON parsing and stringification
- Data interchange with APIs
- Object manipulation
- Error handling
๐ Web Functions
- URL parsing and encoding/decoding
- Base64 operations and URL-safe encoding
- HTTP resource access and API integration
- Cross-origin communication support
๐ฏ ID Generation Functions
- UUID generation (RFC4122)
- Short IDs (NANOID)
- Random data generation (SECURE_RANDOM, MCOOKIE)
- Temporary file paths (MKTEMP)
- Cryptographic security
๐ป System Information Functions
- User info (WHOAMI, USERINFO, LOGNAME, GROUPS)
- System details (HOSTNAME, UNAME, ARCH, NPROC, UPTIME, DNSDOMAINNAME)
- Environment variables (ENV, GETENV)
- System configuration (GETCONF)
- Terminal detection (TTY)
- Network info (IFCONFIG, HOST)
- Compression (GZIP, GUNZIP, ZCAT)
- Process management (KILL, TIME)
- Utilities (SEQ, SHUF, FACTOR, CAL, WHICH, GETOPT, XARGS, ASCII, SLEEP, TRUE, FALSE, YES)
โ Validation Functions
- Email, URL, and phone number validation
- Network address validation (IP, MAC)
- Data type and format verification
- Financial and geographic validation
๐ Security Functions
- Hash functions (MD5, SHA1, SHA256, SHA384, SHA512)
- Checksums (CKSUM, CRC32, SUM_BSD)
- Encoding (BASE64, BASE32, HEX, UUENCODE, UUDECODE)
- Hex utilities (XXD, HEXDUMP, OD)
- Password hashing (MKPASSWD)
- HMAC generation
- JWT token handling
- Cryptographic operations
๐พ File System Functions
- Unix file operations (CAT, CP, MV, RM, TOUCH, LINK, LN, TRUNCATE, UNLINK)
- Directory operations (MKDIR, RMDIR, LS, FIND, DU)
- Path utilities (BASENAME, DIRNAME, PATH_RESOLVE, READLINK)
- File permissions (CHMOD, CHOWN, CHGRP, INSTALL)
- File comparison (CMP, COMM) and disk usage (DU)
- File synchronization (FSYNC, SYNC)
- Unified localStorage and HTTP resource access
- Backup management and data persistence
๐ Excel Functions
- Logical functions (IF, AND, OR, NOT)
- Statistical calculations (AVERAGE, MEDIAN, STDEV)
- Lookup functions (VLOOKUP, HLOOKUP, INDEX, MATCH)
- Text manipulation (CONCATENATE, LEFT, RIGHT, MID)
- Date operations (TODAY, YEAR, MONTH, DAY)
- Financial calculations (PMT, FV, PV, NPV, IRR)
Advanced Functions
๐ R-Language Functions
- Statistical computing and data analysis (150+ functions)
- Matrix operations and linear algebra
- Data manipulation and transformation
- Graphics and visualization
- Machine learning and time series analysis
- Complete R-language compatibility layer
๐ฌ SciPy Interpolation Functions
- Advanced interpolation methods (16+ functions)
- 1D/2D interpolation with multiple algorithms
- Spline functions and scattered data interpolation
- Radial basis functions and shape-preserving methods
- Scientific computing and numerical analysis
๐ Regular Expression Functions
- Pattern matching and text processing
- Full JavaScript regex engine support
- Capture groups and advanced matching
- Text extraction and transformation
Advanced Features
๐ Dynamic Execution
- INTERPRET statement modes
- Variable scoping and isolation
- Security controls (NO-INTERPRET)
- Meta-programming patterns
- Code generation techniques
๐ก Application Addressing
- ADDRESS statement for cross-application communication
- ADDRESS HEREDOC patterns for domain-specific languages
- Secure iframe integration and postMessage protocols
- API integration and authentication workflows
- Multi-application automation patterns
๐ฌ Output and Debugging
- SAY statement with variable interpolation
- Structured logging and audit trails
- Debug workflows and progress tracking
- Error reporting and diagnostics
- Function Discovery - INFO() and FUNCTIONS() for exploring available functions
- INFO(functionName) - Get detailed metadata (module, category, description, parameters, examples)
- FUNCTIONS() - List all functions grouped by module
- FUNCTIONS(category) - List functions by category (String, Math, Array, DOM, etc.)
- FUNCTIONS(module) - List functions from specific module
- Dynamic metadata registration for REQUIREโd modules
๐ฎ DOM Functions
- Browser DOM query and manipulation (Autonomous Web Mode)
- Element interaction (click, type, select)
- CSS style and class management
- Web automation and testing capabilities
- Chainable DOM operations - All ELEMENT mutations return elements for pipeline composition
- DOM Pipeline Functions - Filter and extract data from DOM elements in pipelines
- FILTER_BY_ATTR, FILTER_BY_CLASS - Filter elements by attributes or classes
- GET_VALUES, GET_TEXT, GET_ATTRS - Extract data from elements (returns REXX stem arrays)
๐ DOM Scoped Interpreters
- Multiple REXX scripts with isolated function registrations
- RexxScript CSS class for automatic scope detection
- Functions stored in element.__rexxFunctions instead of global window
- Multi-tenant application support and zero namespace pollution
- Backward compatible opt-in feature with full isolation control
- Interactive demo:
/core/src/repl/dom-scoped-rexx.html
๐ Control Bus
- General-purpose distributed application coordination
- CHECKPOINT function for progress monitoring and flow control
- Director/Worker patterns and event loops
- Multi-application workflow orchestration
- Fault tolerance and error recovery
๐ฆ REQUIRE System
- Dynamic library loading including from GitHub releases
- Zero-overhead detection and caching
- Transitive dependency resolution with circular detection
- Minification-safe dependency metadata
- Multi-mode compatibility (Autonomous Web, Controlled Web, Command-line)
- Library publishing conventions and best practices
โ ๏ธ Error Handling
- Enhanced error context functions (ERROR_LINE, ERROR_FUNCTION, etc.)
- SIGNAL statement usage (SIGNAL ON ERROR, SIGNAL OFF ERROR)
- Error recovery patterns and smart retry logic
- Integration with built-in functions and DOM operations
- JavaScript stack trace integration for debugging
- Best practices for robust error handling
Specialized ADDRESS Handlers
๐ง ADDRESS System
- System command execution and process management
- Environment variable access and configuration
- Cross-platform file system operations
- Process coordination and automation
๐๏ธ ADDRESS SQLite
- Database operations and query execution
- Transaction management and data persistence
- Schema creation and migration patterns
- Data analysis and reporting workflows
๐ฏ ADDRESS HEREDOC Patterns
- Multiline content handling with HEREDOC syntax
- Domain-specific language integration
- Clean syntax for SQL, JSON, XML, and templates
- Migration from legacy MATCHING patterns
๐ ADDRESS Variable Patterns
- Dynamic ADDRESS target resolution
- Variable-based routing and dispatch
- Runtime configuration and target selection
- Flexible automation architectures
๐ ๏ธ ADDRESS Handler Utilities
- Common utility functions for ADDRESS handlers
- Handler development patterns and best practices
- Error handling and validation utilities
- Testing and debugging support for custom handlers
Language Extensions
โจ AS Clause Reference
- Variable aliasing and transformation patterns
- Data type conversion and formatting
- Output redirection and capture
- Advanced parameter passing techniques
๐ Assertions and Expectations
- Built-in assertion functions for testing and validation
- EXPECT statement for behavior verification
- Test-driven development patterns
- Quality assurance and debugging support
๐ REQUIRE Statement
- Detailed REQUIRE statement syntax and semantics
- Registry-based library loading with namespace verification
- Dynamic loading patterns and best practices
- Dependency management and version control
- Library development and publishing guidelines
๐ป REPL Guide
- Interactive RexxJS development environment
- REPL-specific features and commands
- Debugging and exploration techniques
- Development workflow integration
๐ค Interpolation Patterns
- Complete INTERPOLATION PATTERN statement reference
- Predefined and custom interpolation patterns
- Pattern lifecycle management and validation
- Integration with ADDRESS HEREDOC blocks
๐ Function Discovery
- Runtime function introspection with INFO() and FUNCTIONS()
- Get detailed metadata about any function
- Filter functions by category, module, or name
- Dynamic metadata registration for custom libraries
- Self-documenting code libraries
Reference Materials
๐ Function Reference
- Comprehensive cross-reference catalog (470+ functions)
- Implementation status and environment compatibility
- Unix-style command-line tools (85+ text and file operations)
- Function availability by category and use case
- Cross-reference index for all built-in functions
๐งช Testing with rexxt
- Native test runner for RexxJS code
- Execution-based testing without formal suites
- ADDRESS EXPECTATIONS integration patterns
- Test discovery, filtering, and reporting
- Dogfooding and comprehensive testing strategies
Navigation Tips
- Quick Reference: Each function includes practical examples and usage patterns
- Cross-References: Related functions are linked at the bottom of each section
- Integration Examples: Most sections show how features work together
- Error Handling: Security and error handling patterns included throughout
Total Functions: 500+ built-in functions across all categories (with dynamic registration support for custom libraries) Language Features: Complete Rexx implementation with modern enhancements Unix Compatibility: 85+ Unix command-line tools for text and file operations Security: Sandboxing, isolation, and cryptographic functions built-in Function Discovery: INFO() and FUNCTIONS() reflection system for runtime exploration Pipeline Operations: FILTER_BY_ATTR, FILTER_BY_CLASS, GET_VALUES, GET_TEXT, GET_ATTRS for DOM data extraction Chainable DOM: All ELEMENT mutations return elements for seamless pipeline composition
๐ Function Libraries
- Builtโins vs thirdโparty
- Positional vs named arguments
- External script CALL semantics
- COPY() and passโby semantics