Cleans an array by removing blank elements and/or removing duplicates.
NewArray = SRP_Array("Clean", Array, Option, Delim)
Returns
The cleaned array.
Parameters
Parameter | Description |
---|---|
Array | The dynamic array to be cleaned. (REQUIRED) |
Option | Determines the kind of clean operation to perform. (OPTIONAL) |
Delim | The delimiter that separates the elements in the given Array. (OPTIONAL) |
Remarks
Need to tidy up your array? Use the Clean service to quickly remove blanks and duplicates from your dynamic array. Simply pass it your array and its delimiter. You can use the Option parameter to control the cleaning process.
- To remove duplicates in addition to removing blanks, set the Option parameter to "TrimAndMakeUnique".
- To remove only trailing blanks, set the Option parameter to "TrimTrailing". Doing so will leave blanks inside the array and only remove blanks at the end of the array.
- Omitting the Option parameter or setting it to "Trim" will simply remove all blanks, including trailing blanks.
The Delim paramater can also be omitted, in which case it will assume @FM.
Note: This only operates at a 1-dimensional level. This will not work as expected with 2-dimensional data returned from controls like the EDITTABLE.
Examples
// Remove blanks Array = "Don":@FM:@FM:@FM:"Don":@FM:@FM:@FM:"Paul":@FM:@FM:@FM:"Frank":@FM:@FM:@FM:"Bob":@FM:@FM:@FM NewArray = SRP_Array("Clean", Array) // NewArray will be "Don":@FM:"Don":@FM:"Paul":@FM:"Frank":@FM:"Bob" // Remove all blanks using custom delimiter Array = "Don~~Don~~Paul~~Frank~~Bob~~" NewArray = SRP_Array("Clean", Array, "Trim", "~") // NewArray will be "Don~Don~Paul~Frank~Bob" // Remove blanks and duplicates Array = "Don~~Don~~Paul~~Frank~~Bob~~" NewArray = SRP_Array("Clean", Array, "TrimAndMakeUnique", "~") // NewArray will be "Don~Paul~Frank~Bob" // Remove only trailing blanks Array = "Don":@FM:@FM:@FM:"Don":@FM:@FM:@FM:"Paul":@FM:@FM:@FM:"Frank":@FM:@FM:@FM:"Bob":@FM:@FM:@FM NewArray = SRP_Array("Clean", Array, "TrimTrailing", @FM) // NewArray will be "Don":@FM:@FM:@FM:"Don":@FM:@FM:@FM:"Paul":@FM:@FM:@FM:"Frank":@FM:@FM:@FM:"Bob"