|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > ASA. - Associative Array > Assoc. Array Management > ASA. - Associative Array Operations |
SPR Script Language
ASA.Show
Displays a visual representation of an associative array structure.
Intention
The ASA.Show command creates a visual representation of your associative array, making it easier to understand its structure and contents. It's like getting an X-ray of your data structure—showing you all keys, values, and how they're organized in the tree. This is particularly helpful when debugging your SPR scripts or when you need to verify that your array contains what you expect.
You can use ASA.Show in two ways: either display the tree structure directly to a console window (great for immediate feedback), or capture the output into a variable (useful for logging or further processing). The display shows each node with its key and value, along with visual connectors that illustrate parent-child relationships in the tree.
Imagine you've built a complex configuration tree with dozens of settings. Instead of retrieving keys one by one, ASA.Show gives you the whole picture at once, making it much easier to troubleshoot or document your data organization.

Output from the code below in Samples
Illustration
📊 Tree Visualization: Show the structure of an associative array containing employee information.
🖥️ Console Output: See the complete tree with keys, values, and hierarchical connections.
📋 Variable Storage: Capture the tree visualization for later use in reports or logs.
Syntax
ASA.Show|$$TRE[|$$TXT]
Parameter Explanation
P1 - $$TRE - (Variable, 5 characters max)
This is the handle of the associative array you want to visualize. It's a 5-character variable (like $$TRE or $$MAP) that was created with ASA.New. The command will generate a visual representation of this array's structure and contents.
P2 - $$TXT - (Optional, Variable, 5 characters max)
This is where the text representation of the tree will be stored. It's an optional 5-character variable (like $$TXT or $$OUT). If you include this parameter, the tree visualization will be stored in this variable rather than displayed directly. If you omit this parameter, the tree structure will be automatically displayed in a console window.
Examples
'***********************************
' ASA.Show - Sample 1: Display to Console
'***********************************
ASA.New|$$TRE|s
ASA.Set|$$TRE|Name|John Smith
ASA.Set|$$TRE|Age|42
ASA.Set|$$TRE|Department|Engineering
ASA.Set|$$TRE|Title|Senior Developer
ASA.Show|$$TRE
MBX.Ready|Check the console for the tree visualization
ASA.End|$$TRE
'
'***********************************
' ASA.Show - Sample 2: Store in Variable
'***********************************
ASA.New|$$TRE|s
ASA.Set|$$TRE|Product|Laptop
ASA.Set|$$TRE|Price|1200
ASA.Set|$$TRE|Category|Electronics
ASA.Set|$$TRE|InStock|Yes
ASA.Show|$$TRE|$$OUT
MBX.Text|Tree Visualization:|$$OUT
ASA.End|$$TRE
MBX.Ready
'
'***********************************
' ASA.Show - Sample 3: Empty Array
'***********************************
ASA.New|$$TRE|s
ASA.Show|$$TRE|$$OUT
MBX.Text|Empty tree visualization:|$$OUT
ASA.End|$$TRE
MBX.Ready
'
Remarks
- The tree visualization shows the complete structure with keys and their corresponding values.
- Hierarchical connections are displayed using lines and symbols (└──, ├──, etc.) to illustrate the tree structure.
- When displaying directly to the console (by omitting $$TXT), a console window will open if one isn't already open.
- The command works with all associative array types (String, Integer, Extended) but formats the values appropriately.
- This command is read-only and doesn't modify the contents of your array.
Limitations
- Very large trees may produce extensive output that's difficult to read in a single view.
- The variable storing the output ($$TXT) might have a character limit if the tree is extremely large.
- Special characters in keys or values may affect the display formatting.
- Invalid tree handles will result in an error message rather than a visualization.
See also:
• ASA.New
• ASA.Set
• ASA.Get