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.SetValNode

Previous Top Next


SPR Script Language

 

ASA.SetValNode

Updates the value of a specific node in an associative array.

 

Intention

 

The ASA.SetValNode command changes the value of a specific node in an associative array in SPR. You give it a node handle (like $$NODE from ASA.First or ASA.Next) and a new value (like $$VAL or "Alice"), and it updates just that node’s value, leaving its key unchanged. This is a precise way to edit data while navigating with ASA.First, ASA.Next, or ASA.Prev, unlike ASA.Set which uses the key directly.

 

Think of a phonebook array—you’re at a node "Alice" → "123-4567", and ASA.SetValNode changes it to "Alice" → "456-7890". Or in a robot script, update a node "Speed" → "3.14" to "Speed" → "2.5" while looping through settings. It’s a targeted tool for tweaking values mid-navigation, keeping your script flexible.

 

Illustration

✏️ Node Edit: At a node with $$NODE (like "Name" → "Alice"), ASA.SetValNode updates it to "Name" → "Bob".
🔍 Precise: Only the value changes—the key stays the same!

 

Syntax

 

ASA.SetValNode|$$NODE|$$VAL

 

Parameter Explanation

 

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

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

 

P2 - $$VAL - (Variable or Value)

This is the new value for the node. It can be a variable (like $$VAL) or a literal value (like "Alice", "50", or "3.14"). SPR updates the node’s value to this—must match the array’s datatype set by ASA.New (String, Quad, or Extended).

 

Examples

 

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

' ASA.SetValNode - Sample 1: Update Node in String Array

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

ASA.New|$$TRE|s

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

ASA.First|$$TRE|$$NOD

ASA.SetValNode|$$NOD|456-7890

ASA.GetVal|$$NOD|$$VAL

MBX.Updated value is $$VAL (should be 456-7890)

MBX.Ready

'

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

' ASA.SetValNode - Sample 2: Update Node in Quad Array

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

ASA.New|$$TRE|i

ASA.Set|$$TRE|Red|50

ASA.First|$$TRE|$$NOD

ASA.SetValNode|$$NOD|75

ASA.GetVal|$$NOD|$$VAL

PRT.Updated Red count is $$VAL (should be 75)

MBX.Ready

'

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

' ASA.SetValNode - Sample 3: Update Node in Extended FP Array

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

ASA.New|$$TRE|f

ASA.Set|$$TRE|Speed|3.14

ASA.First|$$TRE|$$NOD

ASA.SetValNode|$$NOD|2.5

ASA.GetVal|$$NOD|$$VAL

PRT.Updated Speed is $$VAL (should be 2.5)

MBX.Ready

'

 

Remarks

 

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

- $$VAL must match the array’s datatype (String, Quad, Extended)—mismatch might fail silently.

- Only updates the value—key stays the same, unlike ASA.Set which might add a new pair.

- No result returned—use ASA.GetVal to confirm the update.

 

Limitations

 

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

- If $$NODE isn’t valid, it fails silently—no error feedback.

- Can’t change the key—use ASA.Set for that.

 

See also:

 

ASA.First

ASA.Next

ASA.GetVal

ASA.Set