LastSet

Category: Instructions

LastSet is a function in the ProBuilder language used to determine the last index at which a value was set in an array. This function is particularly useful when working with arrays where not all elements are initialized or when you need to find the most recently updated position in the array. If no index in the array has been set, the function returns -1, indicating an uninitialized state.

Syntax:

lastset($var)

Here, $var represents the array variable for which the last set index is to be found.

Example:


$myArray[3] = 50
$myArray[7] = 100
lastIndex = lastset($myArray) // Returns 7

In this example, values are assigned to the elements at indices 3 and 7. The lastset function is then used to find the last index where a value was set, which in this case is 7.

Additional Information:

  • The lastset function is essential for managing arrays efficiently, especially in scenarios where array elements are sparsely populated.
  • Understanding the use of lastset can help in optimizing the performance of scripts by avoiding unnecessary iterations over large arrays.

This function is straightforward but powerful for handling dynamic data structures in financial programming, where the timing and sequence of data updates are critical.

Related Instructions:

  • ArrayMax instructions
  • ArrayMin instructions
  • ArraySort instructions
  • IsSet instructions
  • Unset instructions
  • Logo Logo
    Loading...