/*------------------------------------------------------------------------------
;function:
; InputBox
;
;Author:
; Christophe MELIN (christophe.melin68@outlook.fr)
;
;Action:
; show a dialog box to get an input from a user
;
;Syntax:
; InputBox( $strtitle, $strprompt, $strDefault, $PasswordChar )
;
;Parameters:
; StrTitle : REQUIRED. String value indicating the title of the window
; StrPrompt : REQUIRED. prompt before the input box
; StrDefault : REQUIRED. default value in the input box
;
; PasswordChar : OPTIONAL char to display if masked input
;
;returns:
; string in the the inputbox if OK Button clicked empty string if Cancel buton clicked
;
;Dependencies:
; KiXFormsv 2.47
;-----------------------------------------------------------------------------*/
Function InputBox( $strtitle, $strprompt, $strDefault, optional $PasswordChar )
dim $, $strInput, $rc, $oldVars, $oldMacros
$oldVars = SetOption( "NoVarsInStrings", "ON" )
$oldMacros = SetOption( "NoMacrosInStrings", "ON" )
dim $InputBoxForm
$Inputboxform = CreateObject("Kixtart.Form")
$Inputboxform.FontName = "Tahoma"
$Inputboxform.FontSize = 10
$Inputboxform.ClientHeight = 250
$Inputboxform.ClientWidth = 400
$Inputboxform.text = $strtitle
$Inputboxform.tag = 1
dim $lblInputboxPrompt
$lblInputboxPrompt = $Inputboxform.Label
$lblInputboxPrompt.HEIGHT = 19
$lblInputboxPrompt.LEFT = 10
$lblInputboxPrompt.TOP = 20
$lblInputboxPrompt.WIDTH = $Inputboxform.width - (2 * $lblInputboxPrompt.left)
$lblInputboxPrompt.text = $strprompt
dim $txtInputboxPrompt
$txtInputboxPrompt = $Inputboxform.TextBox
$txtInputboxPrompt.HEIGHT = 25
$txtInputboxPrompt.LEFT = $lblInputboxPrompt.LEFT
$txtInputboxPrompt.TOP = $lblInputboxPrompt.bottom + 5
$txtInputboxPrompt.Text = $strDefault
$txtInputboxPrompt.WIDTH = $lblInputboxPrompt.width
if $PasswordChar
if Trim($PasswordChar)
$txtInputboxPrompt.passwordchar = $PasswordChar
endif
endif
dim $btnInputboxOK
$btnInputboxOK = $Inputboxform.button("OK")
$btnInputboxOK.FONTNAME = "Arial"
$btnInputboxOK.FONTSIZE = 10
$btnInputboxOK.FONTBOLD = 1
$btnInputboxOK.WIDTH = 80
$btnInputboxOK.HEIGHT = 19
$btnInputboxOK.LEFT = 10
$btnInputboxOK.Top = $txtInputboxPrompt.bottom + 10
$btnInputboxOK.OnClick = "$Inputboxform.hide() $Inputboxform.tag=0"
$btnInputboxOK.Default = 1
dim $btnInputboxCancel
$btnInputboxCancel = $Inputboxform.button("Cancel")
$btnInputboxCancel.FONTNAME = "Arial"
$btnInputboxCancel.FONTSIZE = 10
$btnInputboxCancel.FONTBOLD = 1
$btnInputboxCancel.WIDTH = 80
$btnInputboxCancel.HEIGHT = 19
$btnInputboxCancel.LEFT = $btnInputboxOK.left + $btnInputboxOK.width + 10
$btnInputboxCancel.Top = $btnInputboxOK.Top
$btnInputboxCancel.OnClick = '$Inputboxform.hide() $txtInputboxPrompt.Text = ""'
$btnInputboxCancel.Default = 0
$btnInputboxCancel.Cancel = 1
$Inputboxform.ClientHeight = $btnInputboxOK.bottom + 10
$Inputboxform.Center
$=$Inputboxform.Show()
$=$txtInputboxPrompt.SetFocus()
while $Inputboxform.Visible
$=Execute($Inputboxform.DoEvents)
loop
$strInput = $txtInputboxPrompt.Text
$rc = $inputboxform.tag
$Inputboxform = 0
$inputbox = IIF( $rc, "", $strInput )
$ = SetOption( "NoVarsInStrings", $oldVars )
$ = SetOption( "NoMacrosInStrings", $oldMacros )
exit $rc
endfunction