ASA. - Associative Array Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Arrays and Data-Structures > ASA. - Associative Array > Assoc. Array Operation >

ASA. - Associative Array Operations

ASA.GetVal

Previous Top Next


SPR Script Language

 

ASA.GetVal

Retrieves the value from a specific node in an associative array.

 

Intention

 

The ASA.GetVal command lets you grab the value part of a key-value pair in an associative array in SPR. You give it a node handle (like $$NODE from ASA.First or ASA.Next), and it puts the value—like "123-4567" or "3.14"—into $$VAL. This is your way to see the “data” part of a pair when navigating nodes with ASA.First, ASA.Next, or ASA.Prev. Pair it with ASA.GetKey to get the full pair.

 

Imagine a phonebook array—you’re at a node with "Alice" → "123-4567", and ASA.GetVal pulls out "123-4567". Or in a robot script with "Speed" → "3.14", it grabs "3.14". It’s a quick, simple way to check the value as you loop through, perfect for tasks like displaying all values or processing data from your array.

 

Illustration

💡 Value Peek: From a node with $$NODE (like "Name" → "Alice"), ASA.GetVal gives you "Alice".
📋 Result: $$VAL holds the value so you can see or use it!

 

Syntax

 

ASA.GetVal|$$NODE[|$$VAL]

 

Parameter Explanation

 

P1 - $$NOD - (Variable, 5 characters max)

This is the node handle you’re looking at. It’s a 5-character variable (like $$NODE) from ASA.First, ASA.Next, ASA.Prev, or ASA.Last. The command uses this to grab the value.

 

P2 - $$VAL - (Optional, Variable, 5 characters max)

This is where the value goes. It’s an optional 5-character variable (like $$VAL). SPR puts the value here—could be a string (e.g., "Alice"), integer (e.g., "50"), or float (e.g., "3.14")—depending on the array’s datatype set by ASA.New. If the node isn’t valid, it might give a default (like 0 or empty). Skip this if you don’t need the value saved.

 

Examples

 

'***********************************

' ASA.GetVal - Sample 1: Get Value from First Node in String Array

'***********************************

ASA.New|$$TRE|s

ASA.Set|$$TRE|Alice|123-4567

ASA.Set|$$TRE|Bob|987-6543

ASA.First|$$TRE|$$NOD

ASA.GetVal|$$TRE|$$NOD|$$VAL

MBX.First value is $$VAL (should be 123-4567)

MBX.Ready

'

'***********************************

' ASA.GetVal - Sample 2: Get Value from Last Node in Quad Array

'***********************************

ASA.New|$$TRE|i

ASA.Set|$$TRE|Red|50

ASA.Set|$$TRE|Blue|75

ASA.Last|$$TRE|$$NOD

ASA.GetVal|$$TRE|$$NOD|$$VAL

PRT.Last value is $$VAL (might be 75)

MBX.Ready

'

'***********************************

' ASA.GetVal - Sample 3: Get Value After Stepping in Extended FP Array

'***********************************

ASA.New|$$TRE|f

ASA.Set|$$TRE|Temp|23.5

ASA.Set|$$TRE|Speed|3.14

ASA.First|$$TRE|$$NOD

ASA.Next|$$TRE|$$NOD|$$NXT

ASA.GetVal|$$TRE|$$NXT|$$VAL

PRT.Second value is $$VAL (might be 3.14)

MBX.Ready

'

 

Remarks

 

- $$NODE must be valid from ASA.First, ASA.Next, ASA.Prev, or ASA.Last—check if unsure.

- If $$NODE is 0 or invalid, $$VAL might get a default (e.g., 0 or empty string).

- It’s fast and doesn’t change the array—just reads the value.

- The value type matches the array’s datatype (String, Quad, Extended) set by ASA.New.

 

Limitations

 

- $$NODE must be 5 characters—wrong lengths might cause errors.

- If $$NODE isn’t valid, $$VAL might get unpredictable results—no error warning.

- Only gets the value—use ASA.GetKey for the key.

 

See also:

 

ASA.First

ASA.Next

ASA.Prev

ASA.GetKey