|
| 1 | +# Variable Substitutions |
| 2 | + |
| 3 | +BrightScript extension supports variable substitutions in launch.json configurations to make your debugging workflow more flexible and dynamic. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Variable substitutions allow you to avoid hardcoding values in your launch configurations. Instead of specifying static IP addresses or passwords, you can use variables that are resolved at runtime. |
| 8 | + |
| 9 | +## Available Variable Substitutions |
| 10 | + |
| 11 | +| Variable | Description | Behavior | |
| 12 | +|----------|-------------|----------| |
| 13 | +| `${promptForHost}` | Prompts you to enter or select a host IP address | Shows input dialog or device picker when debugging starts | |
| 14 | +| `${promptForPassword}` | Prompts you to enter the device password | Shows password input dialog when debugging starts | |
| 15 | +| `${activeHost}` | Uses the currently active device | Automatically uses pre-configured device, or prompts if none set | |
| 16 | +| `${host}` | References the resolved host value | Can be used in other fields like `deepLinkUrl` | |
| 17 | + |
| 18 | +## `${promptForHost}` - Interactive Host Selection |
| 19 | + |
| 20 | +The most common variable substitution. When used, VS Code will: |
| 21 | +- Show a list of discovered Roku devices (if device discovery is enabled) |
| 22 | +- Allow manual IP entry |
| 23 | +- Remember the last used device |
| 24 | + |
| 25 | +```json |
| 26 | +{ |
| 27 | + "host": "${promptForHost}" |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## `${promptForPassword}` - Interactive Password Entry |
| 32 | + |
| 33 | +Prompts for the developer password when debugging starts: |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "password": "${promptForPassword}" |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## `${activeHost}` - Smart Device Selection |
| 42 | + |
| 43 | +**New!** Uses the currently active device without prompting, but gracefully falls back to prompting if no device is set. This provides the best of both worlds: convenience when you have a preferred device, flexibility when you don't. |
| 44 | + |
| 45 | +### Basic Usage |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "version": "0.2.0", |
| 50 | + "configurations": [ |
| 51 | + { |
| 52 | + "type": "brightscript", |
| 53 | + "name": "Launch with Current Device", |
| 54 | + "request": "launch", |
| 55 | + "host": "${activeHost}", |
| 56 | + "password": "${promptForPassword}", |
| 57 | + "rootDir": "${workspaceFolder}", |
| 58 | + "files": [ |
| 59 | + "manifest", |
| 60 | + "source/**/*.*", |
| 61 | + "components/**/*.*", |
| 62 | + "images/**/*.*" |
| 63 | + ] |
| 64 | + } |
| 65 | + ] |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +### Requirements |
| 70 | + |
| 71 | +To use `${activeHost}` optimally, you should set an active device using one of these methods: |
| 72 | + |
| 73 | +1. **Via Command Palette:** |
| 74 | + - Open Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) |
| 75 | + - Type "BrightScript: Set Active Device" |
| 76 | + - Enter the IP address of your Roku device |
| 77 | + |
| 78 | +2. **Via Device List:** |
| 79 | + - Use the Roku Devices view in the sidebar to select a device (if device discovery is enabled) |
| 80 | + |
| 81 | +3. **Via Debugging Session:** |
| 82 | + - The active device is automatically set when you start a debugging session with `${promptForHost}` |
| 83 | + |
| 84 | +### Fallback Handling |
| 85 | + |
| 86 | +If you use `${activeHost}` but no active device is set, it will automatically fallback to prompting for host selection (same behavior as `${promptForHost}`). |
| 87 | + |
| 88 | +This provides a seamless experience: |
| 89 | +- **When active device is set**: Uses it automatically without prompting |
| 90 | +- **When no active device**: Falls back to the device picker/input dialog |
0 commit comments