# st

Author: Banane Last Modified: 20100204

This library provides functions to use one single variable as a stack.
You're able to push (add to the stack), pop (remove last added entry and return value) and peek (return last added entry's value).
Could be useful for a small interpreter, calculator and such.

ST_Convert(Value,Mode=0)
ST_Debug(OnOff="")
ST_Del(ByRef Stack)
ST_Dim(ByRef Stack)
ST_IsValid(ByRef Stack,Dim=0)
ST_Len(ByRef Stack)
ST_Peek(ByRef Stack)
ST_Pop(ByRef Stack)
ST_Push(ByRef Stack,Value)
ST_Undim(ByRef Stack)

For more details of the functions's parameters and return value, please see it's source code or the document.

#### Remarks

Because there is no documentation available, I decided to extract related information from source file.

For update's details and remarks related to the functions, please see the AutoHotkey Forum: http://www.autohotkey.com/forum/viewtopic.php?t=54153

#### License

nonexistent

#### Example

    ; #Include st.ahk
    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%

    ;Declare our new stack
    ST_Dim(Script)

    ;Create our sample gui, which adds entrys to the stack
    Gui, 1:+ToolWindow

      Gui, 1:Add, Edit, x5 y5 w350 h20 vEdit
      Gui, 1:Add, Edit, x5 y30 w350 h65 +ReadOnly vAll
      Gui, 1:Add, Text, x5 y105 w100 h15 vCount
      Gui, 1:Add, Button, x250 y105 w50 h20 gRun, Show
      Gui, 1:Add, Button, x305 y105 w50 h20 gAdd, Add

      Gui, 1:Show, w360 h130, Stack Example
      Return

    Add:
      ;Retrieve edit content
      GuiControlGet, Edit, 1:
      ;Clear edit
      GuiControl, 1:, Edit,
      ;Add to stack
      ST_Push(Script,Edit)
      ;Update count text
      GuiControl, 1:, Count, % ST_Len(Script)
      Return

    Run:
      ;Loop trough the stack
      Loop, % ST_Len(Script) {
        ;Retrieve current contents
        GuiControlGet, All, 1:
        ;Add new value to old contents
        GuiControl, 1:, All, % All . ST_Pop(Script) . "`n"
        ;Update count text
        GuiControl, 1:, Count, % ST_Len(Script)
      }
      Return

    GuiClose:
      ExitApp