Jump to content

Search step - when nothing is found


cstein

Recommended Posts

Hi Everyone


I have a general question about a search step. According to the help file, if a search step finds something a new token is created and the found segment is executed. If nothing is found, the found segment is never executed.


I have logic requiring that an object reference state variable is updated based on the result of the search, but whether something is found or not. I am searching for a closest idle vehicle, so there is no problem if at least one vehicle is idle - that part works fine. However if no vehicles are idle (i.e. the found segment is never executed) , I would like to make the object reference equal to Nothing (which I can check for in subsequent steps). I'm just struggling to do that because placing the assignment in the found segment when nothing is found obviously doesn't work. This search is performed many times, so the object reference will have a previous value which I need to update (i.e. I can't default it to Nothing). Is there a token return value in the original segment that could indicate whether something/nothing was found? I can't find anything in the help file.


-Chris

Link to comment
Share on other sites

You can use the search steps 'save number found' state assignment in the advanced properties. Then check the state you saved this too on the original branch to assign 'nothing' to your state.


Alternatively, make the search expression 1. This will save, into Token.ReturnValue, (1)*(numberFound). Check your token.returnvalue to see if any were found.

Link to comment
Share on other sites

×
×
  • Create New...