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

Previous Top Next


SPR Script Language

 

ASA.Del

Removes a specific key-value pair from an associative array.

 

Intention

 

The ASA.Del command lets you delete one specific entry from an associative array in SPR. You give it the handle (like $$TRE) and the key you want to remove (like $$KEY), and it takes out that key and its value—like erasing just one name from a phonebook. The array stays alive, and you can keep using it with ASA.Set or ASA.Get. It’s a precise way to clean up your array without wiping everything out like ASA.Clear does.

 

Imagine a phonebook array where you don’t need "Bob" anymore—ASA.Del removes "Bob" and his number, but keeps "Alice" and others. Or in a robot script, if you’re tracking settings and want to drop "Speed" (like "Speed" → "3.14"), this command takes it out cleanly. It’s quick and targeted, perfect for managing your data one piece at a time.

 

Illustration

✂️ Snip One Out: From an array with handle $$TRE, delete "Name" → "Alice" while keeping other pairs.
🔧 Array Stays: After ASA.Del, $$TRE is still good for more work!

 

Syntax

 

ASA.Del|$$TRE|$$KEY

 

Parameter Explanation

 

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

This is the handle of the array you’re working with. It’s a 5-character variable (like $$TRE or $$ARR) from ASA.New. The command uses this to find the array to delete from.

 

P2 - $$KEY - (Variable or String)

This is the key you want to remove. It can be a variable (like $$KEY) or a string (like "Name"). SPR finds this key in the array and deletes it along with its value.

 

Examples

 

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

' ASA.Del - Sample 1: Delete from a String Array

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

ASA.New|$$TRE|s

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

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

ASA.Del|$$TRE|Bob

ASA.Get|$$TRE|Bob|$$VAL

MBX.Bob’s number after delete: $$VAL (should be empty)

MBX.Ready

'

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

' ASA.Del - Sample 2: Delete from a Quad Array

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

ASA.New|$$TRE|i

ASA.Set|$$TRE|Red|50

ASA.Set|$$TRE|Blue|75

ASA.Del|$$TRE|Red

ASA.Count|$$TRE|$$RES

PRT.Count after deleting Red: $$RES (should be 1)

MBX.Ready

'

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

' ASA.Del - Sample 3: Delete from an Extended FP Array

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

ASA.New|$$TRE|f

ASA.Set|$$TRE|Temp|23.5

ASA.Set|$$TRE|Speed|3.14

ASA.Del|$$TRE|Speed

ASA.Get|$$TRE|Speed|$$VAL

PRT.Speed after delete: $$VAL (should be 0 or empty)

MBX.Ready

'

 

Remarks

 

- $$TRE must be valid—check with ASA.Validate if you’re not sure.

- If $$KEY isn’t in the array, nothing happens—no error, just moves on.

- Works for all datatypes (String, Quad, Extended) set by ASA.New—just deletes the pair.

- No result returned—use ASA.Get or ASA.Count to confirm it’s gone.

 

Limitations

 

- $$TRE must be 5 characters—wrong lengths might cause trouble.

- If $$TRE isn’t valid, it might fail quietly—no way to tell without checking.

- Only deletes one key at a time—use ASA.Clear for everything.

 

See also:

 

ASA.New

ASA.Set

ASA.Get

ASA.Count