I'm trying to make a function that looks for a value in an array, but I'm uncertain of how returning values work.
Here's what the function looks like, roughly:
Code: ags
Here's how I'd like to use it:
Code: ags
But as I said, I'm uncertain of how a certain value is returned. I'd just like to return a true/false value depending on if the wanted value is found in the array or not.
Here's what the function looks like, roughly:
function searchArray (int whichvalue) {
int search = 0;
while (search > -1) {
search ++;
if (array[search]==whichvalue) {
? return true; ?
}
if (search == 100) { // 100=array size
? return false; ?
}
}
}
Here's how I'd like to use it:
if (searchArray(1)==true) Display ("bla bla bla");
But as I said, I'm uncertain of how a certain value is returned. I'd just like to return a true/false value depending on if the wanted value is found in the array or not.