Skip to content

earlb710/maven-script-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Repository files navigation

Maven Script Interpreter

A powerful script interpreter for the EBS (Earl Bosch Script) language, featuring a rich JavaFX-based interactive development environment with syntax highlighting, autocomplete, and integrated database support.

Features

  • Custom Scripting Language: Full-featured scripting language with familiar syntax
  • Type Casting: Explicit type conversions with int(), string(), float(), double(), byte(), long(), boolean(), record(), map()
  • Bitmap Type: Define named bit fields within a byte (8-bit) for compact storage of flags and small values
  • Intmap Type: Define named bit fields within an integer (32-bit) for storing larger bit-packed data structures
  • typeof Operator: Get the type of any variable or expression at runtime (e.g., typeof a returns "string")
  • Screen Component Types: Type tracking for JavaFX screen components with typeof returning "Screen.Xxx" format and .javafx property for component introspection
  • Exception Handling: Robust error handling with try-exceptions-when syntax to catch specific or any errors
  • Interactive Console: JavaFX-based IDE with rich text editing
  • Syntax Highlighting: Color-coded syntax for better readability
  • Autocomplete: Intelligent code completion suggestions for keywords, built-ins, and JSON schemas
  • Configurable Colors: Customize console colors via JSON configuration file
  • Database Integration: Built-in SQL support with cursors and connections
  • Type Aliases: Define reusable type aliases for complex types with the typeof keyword
  • Array Support: Multi-dimensional arrays with type safety
  • JSON Support: Native JSON parsing with support for both standard quoted keys and JavaScript-style unquoted keys, validation, and schema support
  • File I/O: Built-in file operations
  • Extensible: Easy to add custom built-in functions

Quick Start

Prerequisites

  • Java 21 or higher
  • Maven 3.x
  • JavaFX 21

Building the Project

cd ScriptInterpreter mvn clean compile

Running the Application

Interactive Console (JavaFX UI)

mvn javafx:run

Command-Line Script Execution

java -cp target/classes com.eb.script.Run <script-file.ebs>

Console Configuration

You can customize the console colors by creating a console.cfg file in the root directory. The file uses JSON format to define color properties for different text styles.

Example console.cfg:

{"colors":{"info": "#e6e6e6", "error": "#ee0000", "warn": "#eeee00", "ok": "#00ee00", "keyword": "#00FFFF", "background": "#000000", "text": "#e6e6e6" } }

See CONSOLE_CONFIG_GUIDE.md for complete configuration options and examples.

Organizing Screen Applications

Best Practice for Screen Apps with Custom CSS:

When creating applications with screens and custom styling, organize your files in a dedicated directory:

my-screen-app/ ├── my-app.ebs # Main EBS script with screen definitions ├── custom-theme.css # Custom CSS for your screens └── README.md # Optional documentation 

This organization:

  • Keeps related files together (easier to manage and deploy)
  • Enables relative CSS paths from the EBS script location
  • Simplifies version control and sharing
  • Provides clear separation between different screen applications

Example:

// In my-screen-app/my-app.ebsscreenmyScreen={"title": "My App"};showscreenmyScreen;// Load CSS from same directory using relative pathcallcss.loadCss("myscreen","custom-theme.css");

See ScriptInterpreter/scripts/examples/css-screen-demo/ for a complete working example.

Language Overview

Basic Syntax

// Variable declarationvarname: string="World";varcount: int=42;varitems: int[5];// Fixed-size arrayvardata: json={"key": "value"};// Standard JSON with quoted keysvarconfig: json={theme: "dark",volume: 80};// JavaScript-style unquoted keys (NEW)varsettings: map={"theme": "dark","volume": 80};// Map type// Control flowifcount>40then{print"Count is large";}// Loopswhilecount>0{printcount;count=count-1;}// Functionsgreet(name: string)returnstring{return"Hello, "+name+"!";}// Function callsvarmessage=callgreet("World");printmessage;// Arraysvarnumbers=[1,2,3,4,5];printnumbers[0];// Access elementsprintnumbers.length;// Get length// Array syntax comparison (see docs/ARRAY_SYNTAX_GUIDE.md for details):vartraditional: int[100];// Uses Object[] storage (boxed Integer)varenhanced: array.int[100];// Uses int[] storage (primitive, faster for large arrays)// Type aliases (typeof keyword)personTypetypeofrecord{name: string,age: int};varperson: personType;person={"name": "Alice","age": 30};// JSON syntaxprintperson;// Print the record// Record literal syntax (cleaner initialization)posTypetypeofrecord{x: int,y: int};varpos=posType{x: 10,y: 20};// No quotes on field namesprintpos.x;// Output: 10// Database operationsconnectdb="jdbc:oracle:thin:@localhost:1521:xe";usedb{cursormyCursor=select*fromuserswhereage>18;openmyCursor();whilecallmyCursor.hasNext(){varrow=callmyCursor.next();printrow.name;}closemyCursor;}closeconnectiondb;

Note on JSON Syntax: The EBS JSON parser supports both standard JSON with quoted keys ({"name": "value"}) and JavaScript-style unquoted keys ({name: "value"}). Both formats can be used interchangeably or mixed in the same document. Unquoted keys must be valid identifiers (letters, digits, underscore) and cannot start with a digit. Keys with special characters (hyphens, spaces, etc.) must be quoted.

Type Casting

The language supports explicit type casting for all data types. Use the format type(value) to cast values:

// String to number conversionsvarstrNum: string="42";varintVal: int=int(strNum);varfloatVal: float=float("3.14");varlongVal: long=long("999999999");// Number to string conversionsvarnumStr: string=string(123);// Between numeric typesvarwholeNum: int=int(3.14);// 3 (truncation)vardecimalNum: double=double(42);// 42.0// Boolean conversionsvarflag: bool=boolean("true");varflagStr: string=string(false);// Byte conversionsvarbyteVal: byte=byte(65);// Casting in expressionsvarstr1: string="10";varstr2: string="20";varsum: int=int(str1)+int(str2);// 30// Casting in conditionalsifint("15")>10then{print"Condition met";}

Supported cast types:

  • int() or integer() - Convert to integer
  • long() - Convert to long integer
  • float() - Convert to floating point
  • double() - Convert to double precision
  • string() - Convert to string
  • byte() - Convert to byte
  • boolean() or bool() - Convert to boolean
  • record() - Cast JSON object to record with type inference
  • map() - Cast JSON object to map (key-value store)

See scripts/test/test_type_casting.ebs for more examples.

typeof Operator

The typeof operator returns the type of a variable or expression as a string:

// Simple typesvara: string="xyz";printtypeofa;// Output: stringvarnum: int=42;printtypeofnum;// Output: int// Record types - shows full structurevarb: record{x: string,y: int};b={"x": "hello","y": 42};printtypeofb;// Output: record{x:string, y:int}// Works with all typesvarflag: bool=true;printtypeofflag;// Output: bool// Can be used in conditionalsiftypeofa=="string"then{print"a is a string";}// Works with cast expressionsprinttypeofint("42");// Output: int

Supported for all types:

  • Primitive types: string, int, long, float, double, bool, byte
  • Complex types: array, json, map, date, record
  • For records, displays the complete structure with field names and types

See scripts/test/test_typeof_operator.ebs for more examples.

Exception Handling

The language supports robust error handling with try-exceptions-when syntax. This allows you to catch specific types of errors or use ANY_ERROR to catch all errors:

// Basic exception handlingtry{varresult=10/0;// Will throw MATH_ERROR}exceptions{whenMATH_ERROR{print"Cannot divide by zero!";}whenANY_ERROR{print"An unexpected error occurred";}}// Capture error message in a variabletry{vardata= #file.read("missing.txt");}exceptions{whenIO_ERROR(msg){print"File error: "+msg;}}// Multiple specific handlerstry{// Some risky operationvarresult=processData();}exceptions{whenDB_ERROR{print"Database error occurred";}whenTYPE_ERROR{print"Type conversion failed";}whenANY_ERROR(errorMsg){print"Unexpected error: "+errorMsg;}}

Available Error Types:

  • ANY_ERROR - Catches any error (catch-all handler, should typically be last)
  • IO_ERROR - File I/O operations, streams, paths
  • DB_ERROR - Database connection and query errors
  • TYPE_ERROR - Type conversion and casting errors
  • NULL_ERROR - Null pointer or null value errors
  • INDEX_ERROR - Array index out of bounds errors
  • MATH_ERROR - Division by zero, arithmetic errors
  • PARSE_ERROR - JSON parsing, date parsing errors
  • NETWORK_ERROR - HTTP and network connection errors
  • NOT_FOUND_ERROR - Variable or function not found errors
  • ACCESS_ERROR - Permission or access denied errors
  • VALIDATION_ERROR - Validation errors

Key Features:

  • Error handlers are checked in order - the first matching handler is executed
  • Use when ERROR_TYPE(varName) to capture the error message in a variable
  • Multiple handlers can be specified for different error types
  • ANY_ERROR should typically be placed last as it catches all errors
  • Try blocks can be nested for granular error handling

Raising Exceptions

You can explicitly raise exceptions using the raise exception statement. This allows you to signal errors from your own code.

Standard Exceptions (from the ErrorType enum) only accept a single message parameter:

// Raise standard exceptions with a messageraiseexceptionIO_ERROR("File not found: config.txt");raiseexceptionVALIDATION_ERROR("Input must be a positive number");raiseexceptionMATH_ERROR("Cannot calculate square root of negative number");// Raise without a message (uses default message)raiseexceptionNULL_ERROR();

Custom Exceptions can have multiple parameters and are identified by any name not in the standard ErrorType list:

// Raise custom exceptions with multiple parametersraiseexceptionValidationFailed("username","must be at least 3 characters");raiseexceptionOutOfBoundsError(10,0,5);// index, min, maxraiseexceptionBusinessRuleViolation("order",12345,"insufficient inventory");

Catching Raised Exceptions:

// Catch standard exceptionstry{raiseexceptionVALIDATION_ERROR("Invalid input");}exceptions{whenVALIDATION_ERROR(msg){print"Validation failed: "+msg;}}// Catch custom exceptions by nametry{raiseexceptionMyCustomError("error details",42);}exceptions{whenMyCustomError(msg){print"Custom error: "+msg;}whenANY_ERROR(msg){print"Caught by ANY_ERROR: "+msg;}}

Note: Both standard and custom exception names are matched case-insensitively. Any unrecognized exception type (not in the standard ErrorType list) is treated as a custom exception.

Map Type

The map type provides a flexible key-value store where keys are strings and values can be any type. Maps are backed by JSON objects and are ideal for dynamic data storage.

// Declare a map variablevarconfig: map={"host": "localhost","port": 8080,"debug": true};// Cast JSON to mapvarjsonData: json={"name": "Alice","age": 30,"city": "NYC"};varuserMap=map(jsonData);// Access values using json functionsvarname=calljson.get(userMap,"name");// "Alice"varage=calljson.getint(userMap,"age");// 30// Modify and add valuescalljson.set(userMap,"city","Los Angeles");// Update existingcalljson.set(userMap,"country","USA");// Add new key// Nested mapsvarnested: json={"user": {"name": "Bob","settings": {"theme": "dark"}}};varnestedMap=map(nested);

Map vs Record vs JSON:

TypeUse Case
mapFlexible key-value store, no schema required
recordType-safe access with predefined field names and types
jsonAny JSON structure including arrays, objects, and primitives

See scripts/test/test_map_type.ebs for more examples.

String Functions

The language provides comprehensive string manipulation functions. A useful function is str.charArray() which returns character codes:

// Get character codes from a stringvartext: string="Hello";varcodes=callstr.charArray(text);printcodes;// Output: [72, 101, 108, 108, 111]// Access individual character codesprintcodes[0];// Output: 72 (character 'H')printcodes[1];// Output: 101 (character 'e')// Use with string lengthprintcodes.length;// Output: 5// Check ASCII valuesvarletter: string="A";varletterCodes=callstr.charArray(letter);printletterCodes[0];// Output: 65 (ASCII code for 'A')

Use cases for str.charArray():

  • Character analysis and validation
  • Custom encoding/decoding operations
  • Character-by-character processing
  • ASCII/Unicode value checking
  • String transformation algorithms

See scripts/test/test_str_chararray.ebs for more examples.

UI Screens

Create interactive UI windows with thread-safe variables:

// Define a screen with variablesscreenmyWindow={"title": "My Application","width": 800,"height": 600,"vars": [{"name": "counter","type": "int","default": 0},{"name": "message","type": "string","default": "Hello"},{"name": "user","type": "record","default": {"name": "John","email": "[email protected]"}},{"name": "employees","type": "array.record","default": {"id": 0,"name": "","salary": 0.0}// Template for new records}]};// Access screen variables using screen_name.var_name syntaxvarcurrentCount=myWindow.counter;printcurrentCount;// Prints: 0// Assign to screen variablesmyWindow.counter=42;myWindow.message="Updated!";// Access record fieldsprintmyWindow.user.name;// Prints: JohnprintmyWindow.user.email;// Prints: john@example.com// Update record valuesmyWindow.user={"name": "Jane","email": "[email protected]"};// Array.record variables - default is a template for new recordsprintmyWindow.employees;// Initially empty: []// Assign array of recordsmyWindow.employees=[{"id": 1,"name": "Alice","salary": 75000},{"id": 2,"name": "Bob","salary": 65000}];// Access array elementsprintmyWindow.employees[0].name;// Prints: AliceprintmyWindow.employees.length;// Prints: 2// Show the screen (new syntax)showscreenmyWindow;// Hide the screen (new syntax)hidescreenmyWindow;// Show it againshowscreenmyWindow;

Screen Features:

  • Screens are created but NOT shown automatically - use show screen <name> to display
  • Each screen runs in its own dedicated thread
  • The thread automatically stops when the screen is closed
  • All screen variables are thread-safe (using ConcurrentHashMap)
  • Access variables via screen_name.var_name syntax (e.g., myWindow.counter)
  • Assign to variables via screen_name.var_name = value (e.g., myWindow.counter = 10)
  • Variable assignments do not trigger screen display
  • Multiple screens can be created and managed independently
  • Supported Variable Types: int, long, float, double, string, bool, byte, date, json, record, and array.record
    • Record types allow storing structured data with multiple fields
    • Access record fields: screenName.varName.fieldName
    • Array.record types store arrays of records with a template for new entries
      • Default value is a single record (template), not an array
      • Variable initializes as empty array and can be populated with records
      • Example: "type": "array.record", "default":{"id": 0, "name": ""}
  • Case-Insensitive JSON Keys: Screen definition JSON uses case-insensitive key lookup
    • Property names like varRef, VarRef, or varref are all treated identically
    • Keys are normalized to lowercase (promptHelpprompttext)
    • String values preserve their original casing
  • Variable References in JSON: Use $variable (without quotes) to reference script variables in JSON
    • Example: "default": $myVar references the script variable myVar
    • With quotes ("$myVar"), it's treated as a literal string
    • See EBS_SCRIPT_SYNTAX.md for details

Dynamic Screen Values with $variable

You can use $variable references (without quotes) to create dynamic screens:

// Define script variablesvaruserName: string="Alice";varuserAge: int=30;varwindowTitle: string="User Profile";// Use $variable references in screen definition (no quotes)screenprofileScreen={"title": $windowTitle,// Dynamic title"width": 800,"height": 600,"vars": [{"name": "name","type": "string","default": $userName,// References userName variable"display": {"type": "textfield","labelText": "Name:"}},{"name": "age","type": "int","default": $userAge,// References userAge variable"display": {"type": "spinner","labelText": "Age:"}}]};showscreenprofileScreen;

Important:

  • Use $variablewithout quotes to reference variables
  • With quotes ("$variable"), it's a literal string, not a reference
  • Variables must exist in scope when the screen is defined
  • Works with any data type (string, int, bool, arrays, JSON objects, etc.)

Console Commands

When using the interactive console:

  • /open <file> - Load a script from file
  • /save <file> - Save the current script
  • /help - Display help information
  • /clear - Clear console output
  • /echo on|off - Toggle statement echo mode
  • /ai setup - Configure AI integration
  • /safe-dirs - Configure trusted directories

Press Ctrl+Enter to execute the script in the editor. Press Ctrl+Space to trigger autocomplete for keywords, built-ins, and JSON properties.

Autocomplete Features

The interactive console provides intelligent autocomplete support (triggered with Ctrl+Space):

EBS Code Autocomplete

  • Keywords: Language keywords (if, then, while, for, function, return, etc.)
  • Built-in Functions: Over 50 built-in functions like print, substring, parseJson, etc.
  • Context-Aware: Shows only relevant suggestions based on context (e.g., built-ins after call or #)
  • Console Commands: Autocomplete for / commands when typing in console

JSON Schema Autocomplete

When editing JSON content (screen definitions, area definitions, display metadata), autocomplete provides:

  • Property Names: Suggests valid property names from JSON schemas

    • Type { then Ctrl+Space to see all available properties
    • Start typing a property name for filtered suggestions (e.g., type "na to see name)
  • Enum Values: Suggests valid enum values for properties with constrained values

    • After "type": ", press Ctrl+Space to see all valid control types (textfield, button, label, etc.)
    • After "alignment": ", see valid alignment options (left, center, right, etc.)

Example:

{"name": "LoginScreen", "type": " ← Ctrl+Space here shows: textfield, button, label, etc."title": ← Ctrl+Space after opening quote shows: property suggestions }

Supported JSON Schemas:

  • screen-definition.json - Top-level screen properties (name, title, width, height, vars, area)
  • area-definition.json - Container properties (type, layout, items, style)
  • display-metadata.json - UI control metadata (type, mandatory, alignment, min, max, etc.)

The autocomplete automatically detects JSON content and provides schema-aware suggestions from all three schemas combined.

Screen Debug Panel (Ctrl+D)

When working with EBS screens, you can toggle a debug panel by pressing Ctrl+D on any screen window. The debug panel appears on the right side and provides real-time information about the screen state:

Panel Layout

The debug panel is divided into two sections with an adjustable divider:

Top Half: 📊 Variables

  • Lists all screen variables with their names, types, and current values
  • Variables are sorted alphabetically for easy lookup
  • Hover over a variable name to see: varName : dataType (e.g., username : string)
  • Hover over a value to see the full content (useful for truncated strings, maps, lists, arrays)

Bottom Half: 🖼️ Screen Items

  • Lists all screen area items from the screen definition
  • Shows the item name with its actual current value from the JavaFX control
  • Hover over an item name to see:
    • Full qualified name: screenName.itemName
    • jfxType: - The JavaFX control type (TEXTFIELD, CHECKBOX, etc.)
    • varRef: - The linked variable reference
    • layout: - The layout position

Copy to Clipboard

Click the 📋 button in the panel header to copy all variables and screen items to clipboard. The format includes:

Screen: myScreen ================================================== 📊 VARIABLES ---------------------------------------- username : string = "john_doe" isActive : bool = true count : int = 42 🖼️ SCREEN ITEMS ---------------------------------------- myScreen.usernameField [TEXTFIELD] varRef: username = "john_doe" myScreen.activeCheck [CHECKBOX] varRef: isActive = true 

Tooltip Styling

  • Tooltips have a larger font (14px) for better readability
  • Tooltips appear after 0.5 second delay to avoid interference with normal interaction

Press Ctrl+D again to hide the debug panel.

Documentation

Project Structure

maven-script-interpreter/ ├── ScriptInterpreter/ # Main project directory │ ├── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── com/eb/ │ │ │ ├── script/ # Core interpreter │ │ │ │ ├── token/ # Lexer and tokens │ │ │ │ ├── parser/ # Parser │ │ │ │ ├── interpreter/ # Interpreter and runtime │ │ │ │ ├── arrays/ # Array implementations │ │ │ │ ├── json/ # JSON support │ │ │ │ └── file/ # File I/O │ │ │ ├── ui/ # User interface │ │ │ │ ├── cli/ # Console components │ │ │ │ ├── ebs/ # Main application UI │ │ │ │ └── tabs/ # Tab management │ │ │ └── util/ # Utilities │ │ └── resources/ │ │ └── css/ # UI styling │ └── pom.xml # Maven configuration ├── ARCHITECTURE.md # Architecture documentation ├── README.md # This file └── CLASS_TREE_LISTER.md # Class hierarchy tool docs 

Architecture Overview

The interpreter follows a classic three-phase architecture:

  1. Lexical Analysis - Source code → Tokens (EbsLexer)
  2. Syntax Analysis - Tokens → Abstract Syntax Tree (Parser)
  3. Interpretation - AST → Execution (Interpreter)

The UI layer provides an interactive console built with JavaFX, featuring:

  • Rich text editing with syntax highlighting
  • Command history and autocomplete
  • Tab-based script management
  • Real-time output display

For detailed architecture information, see ARCHITECTURE.md.

Built-in Functions

The interpreter includes numerous built-in functions:

Type Conversion

  • toInt(), toFloat(), toDouble(), toString(), toBool()

String Operations

  • substring(), length(), indexOf(), replace(), split()
  • toUpperCase(), toLowerCase(), trim()
  • string.contains(str, sub) - Checks if a string contains a substring, returns boolean
  • str.charArray() - Returns an array of integer character codes (Unicode code points) for each character in a string

Array Operations

  • push(), pop(), shift(), unshift()
  • slice(), splice(), join()

Math Functions

  • abs(), min(), max(), round(), floor(), ceil()
  • sqrt(), pow(), random()

File I/O

  • readFile(), writeFile(), appendFile()
  • fileExists(), deleteFile()

JSON Operations

  • parseJson(), stringifyJson()
  • validateJson(), deriveSchema()

Note: Screen definitions use case-insensitive JSON key parsing, where property names are normalized to lowercase. Regular JSON operations (parseJson()) preserve the original key casing.

Date/Time

  • now(), dateFormat(), parseDate()

CSS Operations

  • css.getValue(cssPath, selector, property) - Retrieves a CSS property value from a stylesheet (e.g., css.getValue("css/console.css", ".error", "-fx-fill") returns "#ee0000")
  • css.findCss(searchPath?) - Searches for all available CSS stylesheet files and returns their paths as a string array

Dialog Functions

  • system.inputDialog(title, headerText?, defaultValue?) - Prompts user for text input, returns the entered string
  • system.confirmDialog(message, title?, headerText?) - Shows YES/NO confirmation dialog, returns boolean
  • system.alertDialog(message, title?, alertType?) - Shows message dialog with OK button (alertType: "info", "warning", "error")

Database Support

The interpreter includes built-in database support with:

  • Connection management
  • SQL cursor operations
  • Parameter binding
  • Result set iteration
  • Multiple simultaneous connections

Currently supports Oracle databases via OracleDbAdapter. Additional database adapters can be easily added by implementing the DbAdapter interface.

AI Integration

The interpreter includes built-in AI integration for calling language models. The AI module supports both synchronous and asynchronous operations.

AI Configuration

Configure AI settings using the /ai setup console command, which prompts for:

  • API endpoint URL
  • API key
  • Model name

Synchronous AI Calls

// Simple AI completion (blocks until response)varresponse=callai.complete(systemPrompt,userPrompt,maxTokens,temperature);// ExamplevarsystemPrompt: string="You are a helpful assistant.";varuserPrompt: string="What is the capital of France?";varresult=callai.complete(systemPrompt,userPrompt,100,0.7);printresult;

Asynchronous AI Calls with Callbacks

For non-blocking AI calls that keep the UI responsive:

// Async AI call returns a request IDvarrequestId: int=callai.completeAsync(systemPrompt,userPrompt,maxTokens,temperature,"callbackFunctionName");// The callback function receives a JSON responseonAiComplete(aiResponse: json){varisSuccess: bool=calljson.getBool(aiResponse,"success",false);varresult: string=calljson.getString(aiResponse,"result","");varwasCancelled: bool=calljson.getBool(aiResponse,"cancelled",false);ifisSuccessthen{print"AI Response: "+result;}elseifwasCancelledthen{print"Request was cancelled";}else{print"Error: "+result;}}

Callback Response JSON Fields:

  • success (boolean) - Whether the AI call succeeded
  • result (string) - The AI response text or error message
  • cancelled (boolean) - Whether the request was cancelled

Cancelling AI Requests

Cancel pending AI requests using the request ID:

// Start an async requestvarrequestId: int=callai.completeAsync(system,user,200,0.7,"myCallback");// Cancel it if needed (e.g., user clicks Cancel button)callai.cancel(requestId);

Cancellation Behavior:

  • Cancellation is immediate on the client side
  • The callback receives {"success": false, "cancelled": true, "result": "Request was cancelled"}
  • The underlying HTTP request may continue in the background until it naturally completes
  • From the user's perspective, cancellation is instant

AI Built-in Functions

FunctionDescription
ai.complete(system, user, maxTokens, temp)Synchronous AI call, blocks until response
ai.completeAsync(system, user, maxTokens, temp, callback)Async AI call, returns request ID
ai.cancel(requestId)Cancels a pending async request

Screen Property Updates with scr.setProperty

Update UI controls programmatically (useful in AI callbacks):

// Disable a buttoncallscr.setProperty("screenName.buttonName","disabled",true);// Update text contentcallscr.setProperty("screenName.textAreaName","value","New text content");// Enable button after operationcallscr.setProperty("screenName.buttonName","disabled",false);

Supported Properties:

  • disabled - Enable/disable controls (boolean)
  • value / text - Update text content of TextField, TextArea, Label, or Button

Extension & Customization

Adding Built-in Functions

Add new functions to the Builtins class:

publicstaticObjectmyFunction(Object[] args){// Implementationreturnresult}

Register in the interpreter:

environment.declare("myFunction", newBuiltinInfo(...));

Adding Database Adapters

Implement the DbAdapter interface:

publicclassMyDbAdapterimplementsDbAdapter{// Implement required methods }

Set the adapter in the interpreter:

interpreter.setDbAdapter(newMyDbAdapter());

Running Scripts from Menu Items

You can add menu items that execute EBS scripts bundled as resources. This is useful for utility scripts like configuration editors.

Step 1: Add your script to resources

Place your .ebs script in ScriptInterpreter/src/main/resources/scripts/:

src/main/resources/ └── scripts/ └── my_script.ebs 

Step 2: Add a menu item in EbsMenu.java

MenuItemmyScriptItem = newMenuItem("My Script…"); myScriptItem.setOnAction(e ->{handler.runScriptFromResource("/scripts/my_script.ebs", "My Script")}); // Add to the appropriate menutoolsMenu.getItems().add(myScriptItem);

The runScriptFromResource method:

  • Loads the script from the classpath resources
  • Executes it in a background thread (doesn't block the UI)
  • Updates the status bar during execution
  • Displays errors in the console output if execution fails

Parameters:

  • resourcePath - Path to the script resource (e.g., /scripts/my_script.ebs)
  • scriptName - Friendly name shown in status bar and error messages

Example: Color Editor Menu Item

MenuItemcolorsItem = newMenuItem("Colors…"); colorsItem.setOnAction(e ->{handler.runScriptFromResource("/scripts/color_editor.ebs", "Color Editor")});

Contributing

Contributions are welcome! Areas for enhancement:

  • Additional database adapters
  • More built-in functions
  • Enhanced error messages
  • Performance optimizations
  • Testing infrastructure
  • Additional language features

License

[Specify license here]

Authors

Earl Bosch

Acknowledgments

  • JavaFX for the UI framework
  • RichTextFX for advanced text editing capabilities

About

Maven Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages