For FinalBuilder 5 we've added a new set of actions for storing and retrieving data in stacks and queues. These actions allow you to build up a list of items and then access them them in either a first in, first out (Queue) or first in, last out (Stack) manner. Create a new Stack or Queue using the Define action, and then to add items, use the Push or Insert actions. To use the items in the list, either use the Pop action to access them one at a time, or use the Iterator to perform the same action on each item until the list is empty. The new actions are:
- Stack/Queue define - define a stack or a queue
- Stack/Queue Log Items - write to the log all items
- Stack/Queue Push Items - add a new item or set of items to the list
- Stack/Queue Pop - get an item from the top
- Stack/Queue Peek - get an item without removing it
- Stack/Queue get Count - get the count of how many items are in the list
- Stack/Queue Insert Item - add an item in a particular location in the list
- Stack/Queue is Empty - check if list is empty or not
- Stack/Queue Clear - remove all items from the list
- Stack/Queue Iterator - run child actions for each item in the list
These actions are interesting because it opens up interesting possibilities with recursion and processing lists of data. For example, you may have some process at the start of your build to build up a list, lets say a list of filenames, and maybe this list comes from calling an external process like your version control system. Then you might want to run a set of actions for each of those files, but it's possible that while processing a file you might need to add extra files onto the list. So, you might end up with the following:
Define Stack
Push Items on Stack (from external process)
Is Stack Empty (set variable IsEmpty)
While Action (controlled by IsEmpty)
Pop Stack (into varible CurrentFile)
Do some processing on the CurrentFile
maybe push more items on the stack
Is Stack Empty (set variable IsEmpty)
End While
This "PsudoActionCode" shows that you can control a loop by the amount of data you need to process which may change during the course of processing the data. We haven't found a use for it yet in our build process, but we have had customers ask for these types of data structures. I'd be very interested in seeing how these actions are used in a real build process.