BrightScript Language Examples#

This folder contains 45 comprehensive BrightScript examples demonstrating the language features covered in the BrightScript Language Reference. All examples include on-screen display capabilities using the shared ShowMessage() function from common-functions.brs.

These examples demonstrate BrightScript language features and provide practical coding examples.

Quick Start#

Getting Started with Examples#

To explore the BrightScript language examples:

Option 1: Run All Examples Automatically

  1. Copy ALL .brs files from the examples folder to your BrightSign SD card root
  2. Rename run-all-examples.brs to autorun.brs
  3. Insert SD card and reboot - examples run automatically in sequence

Option 2: Individual Example Testing

  1. Copy desired .brs files to SD card root
  2. Connect via telnet/SSH: telnet [brightsign-ip]
  3. Run specific examples: BrightScript> run("01-hello-world.brs")

Important: All .brs files must be in the SD card root directory for the run() function to work properly.

Learning Path Recommendations#

Beginners: Start with the BrightScript Language Reference documentation, then work through the numbered examples (1-27) sequentially to build foundational skills.

Intermediate: After mastering the basic examples, explore the more complex examples and patterns.

Advanced: Focus on the production examples and advanced patterns for scalable application development.

Language Examples#

The examples in this folder provide hands-on learning for BrightScript language features:

Foundation Examples (1-7): Variables, functions, strings, case sensitivity, basic program structure
Object-Oriented Examples (8-11): “m” scope patterns, factory functions, cross-references, dependency injection
Data Structure Examples (12-13): Queue implementations, state machines
Media Examples (14-17): Video/audio players, image slideshows, complete media applications
System Examples (18-20): Network configuration, registry operations, validation patterns
Production Examples (21-27): Event loops, library patterns, event buses, timers, logging systems

Utility Scripts: common-functions.brs, run-all-examples.brs, file management utilities
Media Files: Sample MP4, MP3, PNG, and JPG files for testing media examples

Essential Information#

File Deployment#

Critical: All .brs files must be in the SD card root directory, not in subfolders, for the run() function to work.

Shared Library#

All examples use common-functions.brs which provides:

  • ShowMessage() - Blue background message display
  • ShowError() - Red background error display
  • ShowSuccess() - Green background success display
  • ClearMessage() - Clear on-screen display

Usage Modes#

  1. Automatic: Rename run-all-examples.brs to autorun.brs for automatic execution on boot
  2. Manual: Connect via telnet/SSH and run individual examples with run("example-name.brs")
  3. Development: Use individual examples to test specific concepts

Development Philosophy#

This guide follows a learn-by-doing approach with hands-on examples that demonstrate BrightScript language features, from basic syntax through advanced patterns used in production applications.

Additional Resources#

BrightScript Documentation:

Production Code Examples:

  • See external/ directory for real-world BrightSign application code
  • Plugin architecture patterns derived from production BrightSign systems
  • Advanced patterns used in digital signage deployments

A complete guide to BrightScript development for BrightSign digital signage players - from basics to production patterns.