Menu: Difference between revisions
Content added Content deleted
Alpha bravo (talk | contribs) (Added AutoHotkey) |
|||
Line 95: | Line 95: | ||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
<lang AutoHotkey>Menu(list:=""){ |
|||
{{incorrect|AutoHotkey|The function should return an empty string if called with an empty list. Please also check if this could really used as a [https://en.wikipedia.org/wiki/Subroutine function aka subroutine.]}} |
|||
if !list ; if called with an empty list |
|||
<lang autohotkey>GoSub, CreateGUI |
|||
return ; return an empty string |
|||
⚫ | |||
for i, v in x := StrSplit(list, "`n", "`r") |
|||
string .= (string?"`n":"") i "- " v |
|||
, len := StrLen(v) > len ? StrLen(v) : len |
|||
while !x[Choice] |
|||
InputBox , Choice, Please Select From Menu, % string ,, % 200<len*7 ? 200 ? len*7 , % 120 + x.count()*20 |
|||
return x[Choice] |
|||
⚫ | |||
Examples:<lang AutoHotkey>list = |
|||
( |
|||
fee fie |
|||
huff and puff |
|||
mirror mirror |
|||
tick tock |
|||
) |
|||
MsgBox % Menu(list) ; call menu with list |
|||
MsgBox % Menu() ; call menu with empty list |
|||
⚫ | |||
Submit: |
|||
Gui, Submit, NoHide |
|||
If Input = |
|||
GuiControl,,Output |
|||
Else If Input not between 1 and 4 |
|||
{ |
|||
Gui, Destroy |
|||
Sleep, 500 |
|||
GoSub, CreateGUI |
|||
} |
|||
Else { |
|||
GuiControlGet, string,,Text%Input% |
|||
GuiControl,,Output,% SubStr(string,4) |
|||
} |
|||
return |
|||
CreateGUI: |
|||
list = fee fie,huff and puff,mirror mirror,tick tock |
|||
Loop, Parse, list, `, |
|||
Gui, Add, Text, vText%A_Index%, %A_Index%: %A_LoopField% |
|||
Gui, Add, Text, ym, Which is from the three pigs? |
|||
Gui, Add, Edit, vInput gSubmit |
|||
Gui, Add, Edit, vOutput |
|||
Gui, Show |
|||
return |
|||
GuiClose: |
|||
⚫ | |||
=={{header|AWK}}== |
=={{header|AWK}}== |