[skip|else] if [not]|while [not] = Possible 'conditional' statements that can be used with this command.
<RetVar/IF> = Command return, with an 'if' statement used it will be TRUE (1) if condition passes or FALSE (0) if it fails, otherwise if you use a Variable it will be the value of TRUE / FALSE as an integer.
<Value> = The value you wish to check for.
<Value> = The array that you want to check the contents of.
Returns TRUE if the value is found.
Ok, let pretend that you want to create a list (array) containing all the different wares that are on ships that you own in your empire. This list only needs to have the entry for each ware in it once.
So, using appropriate commands you could get a list of all your ships, then cycle each one individually and get the wares onboard each ship.
Before you start to cycle all your ships you would create an array to hold the list of individual wares,
$ships.wares.list = array alloc: size = 0
While cycling the wares list you could put,
skip if find $ships.ware in array: $ships.wares.list
| append $ships.ware to array: $ships.wares.list
This would check first to see if that particular ware is already in the $ships.wares.list array, and if it finds it it would continue on but if it doesn't find it it will append the ware to the list. This would result in a list containing only one entry for each ware, but all ships wares would have been checked.
- »» General Commands
- »» Arrays
<RetVar/IF> find <Value> in array: <Value>
- »» Arrays