Arrays

Name -- Syntax / Description
miva_array_binarysearch
miva_array_binarysearch( key, array var, callback, data var )
Performs a binary search for "key" in "array". "array" must have been previously sorted.
Returns the index of "key" in "array" or 0 if no match was found.
  • key = The value that will be searched for.
  • array var = The array that will be searched.
  • callback = The name of a callback function. See below.
  • data var = Optional data that is passed through to the callback function
miva_array_clear
miva_array_clear( array var, start, count )
Removes "count" elements from "array", starting at position "start". The elements are removed from the array, but the array is not collapsed.
Returns the number of elements remaining in the array.
  • array = The array that will be altered.
  • start = the starting index numbert
  • count = the number of elements that will be cleared
miva_array_collapse
miva_array_collapse( aggregate var )
Collapses the array_variable making the indices sequential starting at 1. Returns the number of elements in the array.
miva_array_copy
miva_array_copy( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and placing the elements at "dpos". Existing elements in "dest" are overwritten.
Returns the number of elements in the "dest" array after the copy.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Overlapping elements in "dest" are overwritten.
miva_array_copy_ref
miva_array_copy_ref( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and placing the elements at "dpos". Existing elements in "dest" are overwritten.
Returns the number of elements in the "dest" array after the copy.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Overlapping elements in "dest" are overwritten.
miva_array_delete
miva_array_delete( array var, start, count )
Removes "count" elements from "array", starting at position "start". The array is collapsed after the elements are removed.
Returns the number of elements remaining in the array.
  • array = The array that will be altered.
  • start = the starting index numbert
  • count = the number of elements that will be cleared
miva_array_deserialize
miva_array_deserialize( string )
Reverses miva_array_serialize(). Returns an aggregate array repopulated to match the original.
miva_array_elements
miva_array_elements( aggregate var )
Returns the number of elements in the array_variable that were actually used.
miva_array_filter
miva_array_filter( array var, offset, element var, filter_expression, output var )
Iterate through an array starting at a given offset, execute a filter expression against each element, and copy the member to a new output array. See also miva_array_filter_ref.
Return value: Count of output array elements.
  • array var = Source array of structures.
  • offset = index in the array to start filtering from.
  • element var = Name of a variable to reference in the filter expression.
  • filter_expression = Text of an expression to execute based on the individual array element.
  • output var = Output array of all structures that tested true in the filter expression.
miva_array_filter_ref
miva_array_filter_ref( array var, offset, element var, filter_expression, output var )
Iterate through an array starting at a given offset, execute a filter expression against each element, and create a new member with references to the members in the output array. See also miva_array_filter.
Return value: Count of output array elements.
  • array var = Source array of structures.
  • offset = index in the array to start filtering from.
  • element var = Name of a variable to reference in the filter expression.
  • filter_expression = Text of an expression to execute based on the individual array element.
  • output var = Output array of all structures that tested true in the filter expression.
miva_array_find
miva_array_find( needle, haystack var, offset )
Performs a sequential search for "needle" in array "haystack", starting at "offset". Comparison is equivalent to the EQ operator. (i.e. looks for an exact match). Haystack must be a simple array( no members), or contain no more than 1 member.
Returns the index of "needle" in "haystack" or 0 if the element was not found.
  • needle = value to search for
  • haystack var = the simple array to search
  • offset = the starting index position
miva_array_insert
miva_array_insert( array var, element, pos )
Inserts single element "element" into "array" at position "pos". If "pos" = -1, the element is inserted at the end of "array".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_insert_ref
miva_array_insert_ref( array var, element var, pos )
Inserts single element "element" into "array" at position "pos".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_insert_var
miva_array_insert_var( array var, element var, pos )
Inserts single element "element" into "array" at position "pos".
Returns the number of elements in "array" after the insertion.
  • array = The array tro which the records will be inserted
  • element = the record that will be inserted
  • pos = the index where the element will be inserted.
miva_array_max
miva_array_max( aggregate var )
Return the maximum array_variable index used.
miva_array_merge
miva_array_merge( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and inserting the elements at "dpos". Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
Returns the number of elements in the "dest" array after the merge.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
miva_array_merge_ref
miva_array_merge_ref( source var, sstart, scount, dest var, dpos )
Copies "scount" elements from "source" into "dest", starting with "sstart" and inserting the elements at "dpos". Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
Returns the number of elements in the "dest" array after the merge.
  • source = The source array from which records will be copied
  • sstart = The source starting index
  • scount = The number of source records to copy.
  • dest = The destination array that will receive the copied records.
  • dpos = The starting index within the destination array. Existing elements in "dest" past "dpos" are pushed forward by "scount" elements.
miva_array_min
miva_array_min( aggregate var )
Return the minumum array_variable index used.
miva_array_next
miva_array_next( aggregate var, index )
miva_array_pop
miva_array_pop( array var )
Removes and returns the last element of "array".
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove.
miva_array_pop_ref
miva_array_pop_ref( array var, element var )
Makes "element" a reference to the last element of "array", then removes it from the array.
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove.
miva_array_previous
miva_array_previous( aggregate var, index )
miva_array_search
miva_array_search( array var, offset, element var, filter_expr )
Performs an sequential search in "array", starting at "offset". Comparison is made by evaluating "filter_expr" for each element. This allows you to specify the comparison type.
Returns the index of the first element in "array" for which filter_expr evaluated as true, or 0 if no elements met this condition.
  • array var = the array that will be searched
  • offset = the starting index for the search
  • element var = a variable name used to reference individual array records. See Example 1
  • filter_expr = an expression similar to the EXPR attribute to MvFILTER. See Example 2
miva_array_serialize
miva_array_serialize( aggregate var )
Returns a string representation of the array and any subarrays. Can be used to store an entire array in a database for later retreival.
miva_array_shift
miva_array_shift( array var )
Removes and returns the first element of "array".
Returns the first element of "array".
  • array = the array where the record will be remove.
miva_array_shift_ref
miva_array_shift_ref( array var, element var )
Makes "element" a reference to the first element of "array", then removes it from the array.
Returns the number of elements remaining in "array".
  • array = the array where the record will be remove
  • element = a reference to the element that was removed.
miva_array_sort
miva_array_sort( aggregate var, callback, data var )
This function will sort an array structure
Returns the number of array elements in the aggregate array structure after sorting.
  • Aggregate: The array that will be sorted. (the aggregate will be physically altered on return)
  • Callback: The name of a user function that must exist in your program, defined as Callback(left var, right var, data var)
  • Data: Not directly used in the miva_array_sort(), the value will be passed to the Callback function.
miva_element_exists
miva_element_exists( array var, index )
Tests if an element exists where: array is an array and index is index number being tested.
Returns 1 if the element found else 0
miva_member_exists
miva_member_exists( structure var, member )
Tests if a member exists where: "structure" is a data structure and "member" is the name of a structure member being tested. Returns 0 or 1.
Returns 1 if found else returns 0
  • structure: A data structure or structured array that is tested. It is passed by reference to the function.
  • member: The literal member name or a variable that evaluates as the member name.
miva_struct_members
miva_struct_members( struct var, members var )
This function retreives the member / field names of a data structure.
Returns the number of member names found. Important: A member name will be returned even if its value is null.
  • struct = the structure or structured array that will be processed
  • members = The array populated with the members names found in structure
miva_struct_merge
miva_struct_merge( source var, dest var )
Copy the structure members from source into dest, if the member does not exist in dest. See also miva_struct_merge_ref.
Return value: 0 on success, -1 on failure.
  • source - Structure to copy into dest.
  • dest - Destination structure.
miva_struct_merge_ref
miva_struct_merge_ref( source var, dest var )
Make references of the structure members from source in dest, if the member does not exist in dest. Similar to miva_struct_merge, but makes references into original structure rather than copies.
Return value: None.
  • source - Structure to copy into dest.
  • dest - Destination structure.
miva_struct_member_callback
miva_struct_member_callback( struct var, function, data var )
This function can be used to dynamically populate structure members as they are accessed.
Return Value: Empty
  • struct = The structure that had the member accessed
  • function = a string containing the callback function name that will be triggered when a member does not exist in the structure (if the callback function is empty, the callback will be disabled)
  • data = The data that will be passed to the callback function
User Annotations: arrays