Array Commands
array_equal()
|
---|
Checks the values of two arrays. Returns 1 if all values are equal, 0 if not |
Remarks
This command does not work with arrays of real numbers.
Examples
on init declare %array_1[10] declare %array_2[11] if (array_equal(%array_1, %array_2)) message("Arrays are not equal!") else message("Arrays are equal!") end if end on
This script will produce an error message as the two arrays don't have the same size
See Also
num_elements()
|
---|
Returns the number of elements in an array |
Remarks
With this function you can, e.g., check how many groups are affected by the current event, using
num_elements(%GROUPS_AFFECTED)
.
Examples
on note message(num_elements(%GROUPS_AFFECTED)) end on
Outputs the number of groups that are playing when you press a key
See Also
Events and MIDI: %GROUPS_AFFECTED
search()
|
---|
Searches the specified array for the specified value and returns the index of its first position. If the value is not found, the function returns -1. |
Remarks
This command does not work with arrays of real numbers.
Examples
on init declare ui_table %array[10] (2, 2, 5) declare ui_button $check set_text($check, "Zero present?") end on on ui_control ($check) if (search(%array, 0) = -1) message("No") else message("Yes") end if $check := 0 end on
Checking if a specific value is present in an array
See Also
sort()
| |
---|---|
Sorts an array in ascending or descending order. | |
| The array to be sorted |
| When equal to 0, the array is sorted in ascending order When not equal to 0, the array is sorted in descending order |
Examples
on init declare $count declare ui_button $Invert declare ui_table %array[128] (3, 3, 127) while ($count < 128) %array[$count] := $count inc($count) end while end on on ui_control ($Invert) sort(%array, $Invert) end on
Quickly inverting a linear curve display