-
Notifications
You must be signed in to change notification settings - Fork 3
/
_InputBox.bat
76 lines (76 loc) · 3.6 KB
/
_InputBox.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
::'@ECHO OFF
::'SETLOCAL ENABLEDELAYEDEXPANSION&::(Don't pollute the global environment with the following)
::'::**********************************************************************
::'SET $NAME=%~n0
::'SET $DESCRIPTION=Input routine for batch using VBScript to provide input box
::'SET $AUTHOR=Stephen Knight, October 2009, http://www.dragon-it.co.uk/
::'SET $SOURCE=%~f0
::'::@(#)NAME
::'::@(-) The name of the command or function, followed by a one-line description of what it does.
::'::@(#) %$NAME% -- %$DESCRIPTION%
::'::@(#)
::'::@(#)SYNOPSIS
::'::@(-) In the case of a command, a formal description of how to run it and what command line options it takes.
::'::@(-) For program functions, a list of the parameters the function takes and which header file contains its definition.
::'::@(-)
::'::@(#) %$Name% [Window title] [Message] [Default value]
::'::@(#)
::'::@(#)OPTIONS
::'::@(-) Flags, parameters, arguments (NOT the Monty Python way)
::'::@(#) -h Help page
::'::@(#)
::'::@(#)DESCRIPTION
::'::@(-) A textual description of the functioning of the command or function.
::'::@(#) Prompting user for simple text input using input box
::'::@(#)
::'::@(#)EXAMPLES
::'::@(-) Some examples of common usage.
::'::@(#) SET _INPUT=
::'::@(#) SET _TITLE=window title
::'::@(#) SET _MSG=Hello world.{CrLf}Please enter something for me:
::'::@(#) SET _CMD=CALL %$NAME% "%_TITLE%" "%_MSG%" "default"
::'::@(#) FOR /F "tokens=* delims=" %%a IN ('CALL %_CMD%') DO SET _VAR=%%a
::'::@(#) ECHO You entered [%_VAR%]
::'::@(#)
::'::@ (#)EXIT STATUS
::'::@(-) Exit status / errorlevel is 0 if OK, otherwise 1+.
::'::@(#) The following exit values are returned:
::'::@(#) 0 Any matches were found.
::'::@(#) 1 No matches found.
::'::@(#)
::'::@(#)REQUIRES
::'::@(-) Dependecies
::'::@(#) _Debug.cmd Setting up debug environment for batch scripts
::'::@(#) _GetOpt.cmd Parse command line options and create environment vars
::'::@(#)
::'::@(#)SEE ALSO
::'::@(#) _MsgBox.bat
::'::@(#)
::'::@(#)REFERENCE
::'::@(#) Stephen Knight, October 2009, http://www.dragon-it.co.uk/
::'::@(#) URL: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-gui-inputbox!OpenDocument
::'::@(#)
::'::@(#)SOURCE
::'::@(#) %$Source%
::'::@(#)
::'::----------------------------------------------------------------------
::':: History
::'::SET $VERSION=YYYY-MM-DD&SET $REVISION=hh:mm:ss&SET $COMMENT=Init / Description [xx.xxx]
::'::SET $VERSION=2010-10-13&SET $REVISION=15:36:00&SET $COMMENT=ErikBachmann / Initial: FindInPath [01.000]
::'::SET $VERSION=2014-01-11&SET $REVISION=10:59:00&SET $COMMENT=Update doc + example/ErikBachmann [01.002]
::'::SET $VERSION=2015-02-18&SET $REVISION=19:32:00&SET $Comment=cmdized/ErikBachmann
::' SET $VERSION=2015-10-21&SET $REVISION=19:05:00&SET $Comment=Update usage/ErikBachmann
::'::**********************************************************************
::'::@(#)(c)%$VERSION:~0,4% %$Author%
::'::**********************************************************************
::'CALL "%~dp0_debug"
::'CALL "%~dp0_GetOpt" %*&IF ERRORLEVEL 1 EXIT /B 1
::'
::'"%windir%\System32\cscript.exe" //nologo //e:vbscript "%~f0" %*
::'goto :EOF
Set args = Wscript.Arguments
x=InputBox(Replace(WScript.Arguments.Item(1),"{CrLf}", vbCrLf),WScript.Arguments.Item(0),WScript.Arguments.Item(2))
wscript.echo x
' http://www.vistax64.com/vb-script/192365-return-value-vbscript-cmd-file.html
'
'*** End of File ******************************************************