====FOR==== ===Parameters=== ^Order^Name^Type^Desc^ |1|func|[[function|function]]|The function to execute for every item in the list| ===Returns=== Calls //func// for every item on the stack, placing all of the results onto the stack. ===Description=== This command runs the //func// function for every item that is currently on the stack. This command is primarily a convenience command. It allows you to avoid repeating parts of your query. ===Example=== To demonstrate the function, let's look at a simple example. **'Alpha' [[fASSET]] 'Beta' [[fASSET]] 'Gamma' [[fASSET]] [[fRELS]]** will return a single list of relationships that are present on //any// of the three assets. This might be useful in some scenarios, but we'd like to know which relationships are present in the individual assets. We could do this by doing the same basic function three times... **'Sensor 1' [[fASSET]] 'Temperature' [[fPROPERTY]] [[mVALUES]] 'Sensor 2' [[fASSET]] 'Pressure' [[fPROPERTY]] [[mVALUES]] [ { "range": "2 Hours", "grain": -100 } [[fGETHISTORY]] ] FOR** By the time the 'FOR' command is reached, there are two point-lists on the stack - one for //Sensor 1 temperature//, one for //Sensor 2 pressure//. The 'FOR' command in this case will run the function (using GETHISTORY to grab the most recent 2 hours of data) once for each of those point lists. Note that this is a trivial example - in this case, you'd normally make this query using **('Sensor 1','Sensor 2') ASSET ('Temperature','Pressure') PROPERTY VALUES { "range": "2 Hours", "grain": -100 } GETHISTORY** instead. [[fEACH]] is a similar loop function used to iterate over a //list// rather than the //stack//. ===See Also=== [[fEACH]] \\ [[fNAME]] \\ [[fSTACKCOUNT]] \\