|
<< 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.EndAll
Destroys all associative arrays in the script, freeing their memory.
Intention
The ASA.EndAll command is a big cleanup tool for SPR. It wipes out every associative array you’ve made with ASA.New in your script—no matter how many there are or what their handles are (like $$TRE or $$ARR). This frees up all the memory they were using in one go. It’s perfect when your script is done and you want to start fresh, or if you’ve lost track of all the arrays you created. Unlike ASA.End, which cleans up just one array, ASA.EndAll takes care of everything at once.
Picture this: you’ve got a bunch of phonebooks, robot setting lists, or inventory tables in your script—maybe dozens of them! Instead of using ASA.End on each one (and needing to remember all their handles), ASA.EndAll sweeps them all away with one command. It’s like hitting a reset button for all your associative arrays. Use it at the end of a big script or when you’re switching to a new task and don’t need any old data hanging around.
Illustration
🧹 Total Cleanup: Arrays with handles like $$TR1 and $$TR2 holding data (e.g., "Name" → "Alice", "Count" → "10") all get erased.
🔥 All Gone: After ASA.EndAll, no arrays are left—your script’s memory is clean and ready for new work!
Syntax
ASA.EndAll
Parameter Explanation
This command has no parameters! Just use ASA.EndAll by itself, and it takes care of everything.
Examples
'***********************************
' ASA.EndAll - Sample 1: Clear Multiple String Arrays
'***********************************
ASA.New|$$TR1|s
ASA.Set|$$TR1|Name|Alice
ASA.New|$$TR2|s
ASA.Set|$$TR2|City|Berlin
ASA.EndAll
MBX.Text|All arrays are destroyed!
MBX.Ready
'
'***********************************
' ASA.EndAll - Sample 2: Clear Mixed Datatype Arrays
'***********************************
ASA.New|$$TR1|i
ASA.Set|$$TR1|Count|500
ASA.New|$$TR2|f
ASA.Set|$$TR2|Speed|3.14
ASA.EndAll
PRT.All integer arrays gone
PRT.All floating-point arrays gone
MBX.Ready
'
'***********************************
' ASA.EndAll - Sample 3: Reset After Complex Script
'***********************************
ASA.New|$$TR1|s
ASA.Set|$$TR1|Robot|RX-500
ASA.New|$$TR2|i
ASA.Set|$$TR2|Steps|1000
ASA.New|$$TR3|f
ASA.Set|$$TR3|Temp|25.5
ASA.EndAll
PRT.Robot data cleared
PRT.Steps data cleared
PRT.Temperature data cleared
MBX.Ready
'
Remarks
- ASA.EndAll doesn’t care what type of arrays you have (String, Quad, or Extended)—it wipes them all out.
- After running this, all handles (like $$TR1 or $$TR2) become invalid—check with ASA.Validate if you need to be sure.
- There’s no way to undo this or get a result back—it’s a one-way cleanup!
- Use ASA.End if you only want to clear one specific array instead of everything.
Limitations
- You can’t pick and choose which arrays to destroy—it’s all or nothing.
- If no arrays exist, ASA.EndAll still runs but does nothing—no error, no warning.
- Once cleared, you’ll need ASA.New to start over with new arrays.
See also:
• ASA.New
• ASA.End
• ASA.Set