IsSet

Category: Instructions

IsSet is a function in the ProBuilder language used to determine if a specific index of an array has been initialized or set within the code. This function is particularly useful for managing arrays where not all elements are guaranteed to be assigned a value. The function returns 1 if the index has been set, and 0 if it has not.

Syntax:

ISSET($MyArray[arrayColumn])

Here, $MyArray represents the name of the array, and Index is the specific index of the array you want to check.

Example:


// Set values for some indices
$MyArray[0] = 10
$MyArray[2] = 30

// Check if the indices are set
ISSET($MyArray[0]) // Returns 1
ISSET($MyArray[1]) // Returns 0
ISSET($MyArray[2]) // Returns 1
ISSET($MyArray[3]) // Returns 0

This example demonstrates how IsSet can be used to verify whether specific indices in an array have been assigned values. The function returns 1 for indices 0 and 2 where values were set, and 0 for indices 1 and 3 where no values were assigned.

Additional Information:

  • The IsSet function is essential for avoiding errors in scripts that dynamically handle arrays whose size or content might vary during execution.
  • It helps in writing more robust and error-free code by ensuring that operations on array elements are performed only when values are indeed present.

Understanding and using the IsSet function can significantly enhance the reliability and efficiency of array operations in ProBuilder scripts.

Related Instructions:

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