Skip to content

findall

MicroBlaster edited this page Jul 9, 2020 · 4 revisions

Purpose: Finds all occurrences of the specified value in an array of strings.

Syntax: FindAll [SourceArray] [FoundArray]

SourceArray: The source array to be searched.
FoundArray: An array to hold the resulting list of found items.

Notes: You can use FindAll on a sorted or unsorted array of strings.

Example:

# Create an array.
$Names[1] := "Fleet Admiral Clausewitz"
$Names[2] := "Captain Zyrain"
$Names[3] := "Captain Wilson"
$Names[4] := "Admiral Nelson"

# Search for the all occurrences of "Admiral".
findAll $Names $Found "Admiral"

# Sort the result (Optional)
sort $Found $Sorted

# Display the results.
echo "Found " $Sorted " matching items.*"
$i := 1
while $i <= $Sorted
    echo $Sorted[$i] "*"
    $i++
end

:Done
echo "That's all Folks!*"

Clone this wiki locally