Like Paper...or Pancakes
A stack is very much like a stack of paper (or pancakes).
When you execute a Step which has a return value, that value is put on the top of the stack. You can then use the items on the stack for subsequent Steps in whatever way you need.
Each time something is added to the stack, it goes on top of the previous item.
So when you pop (pull) something from the stack, the value below it is the next item on the top of the stack.
You can also peek (leave) whatever is currently on the top of the stack without removing it.
In this example, we will get the title of the foreground window and display it in a message box.
This requires 3 Steps:
- Get the foreground window
- Get the window text (title)
- Display the message box
Get Foreground Window
Get the foreground window and push it onto the top of the stack. There is now 1 item on the stack.
Get Window Text (Title)
Pull the foreground window object from the stack and get the window title, then push the title onto the stack.
Since the window was removed from the stack, now only the title is on the stack.
Show Message Box
Pull the title from the stack to use as the message value. The stack is now empty.
Use direct input for the message box title.
When we execute this Steps sequence, we see a message box with the foreground window title.