Ask - Help

ASK Ver 0.12 (2018-07-24)

A program to get user input.

Ask is one of the Batch Tools.

USAGE

The usage message is:

ask.exe usage
ask.exe usage

You can get the usage message by typing in any wrong combination, "ask" by itself, or "ask -?".

Usage 1

To present a choice between [Ok] and [Cancel], use the "ok" command, like this:

C:\Demo>ask ok "Convert the video?" out.txt

This produces:

ask.exe ok?
ask.exe ok?

If the user clicks [Ok] then out.txt will contain "ok". Otherwise, it will be blank.

Usage 2

This is similar to the first use but it presents a [Yes] [No] set of buttons. An example is:

C:\Demo>ask yn "Email the report?" out.txt

This produces:

ask.exe yes/no
ask.exe yes/no

If the user clicks [Yes] then out.txt will contain "yes". Otherwise, it will be blank.

Usage 3

If you need some actual text from the user, you can use:

C:\Demo>ask text "Street address?" out.txt

This produces:

ask.exe text
ask.exe text

"out.txt" will contain the text entered by the user, unless they clicked [Cancel] in which case "out.txt" will be blank.

Note: you can also enter text and press the Enter key at the end. This is the same as clicking [Ok]. The text will be written to "out.txt". If you press the [esc] key at any point, the input will be cancelled and "out.txt" will be blank. You don't have to click anything after pressing the [enter] or [esc] key - the input box closes and your program proceeds.

In some cases, you may prefer the input box to have [Back] and [Next] buttons or [Back] and [Done] buttons. The options "-bn" and "-bd" make those happen. You can specify either; but you can't specify both.

Usage 4

Sometimes you want a user to pick from a set of choices. You can do this by:

C:\Demo>type dsk-fmts.csv
5 inch Single-sided Single Density,/51S
5 inch Single-sided Double Density,/51D
5 inch Double-sided Single Density,/52S
5 inch Double-sided Double Density,/52D

C:\Demo>ask list "What type of disk do you want to format?" dsk-fmts.csv out.txt

This produces:

ask.exe list
ask.exe list

The list file ("dsk-fmts.csv" in the above example) is a comma separated value (CSV) file with two columns. The first column is what gets displayed. The second column is what gets written as the choice. As usual with CSV files, you can quote the values in it (like: "5 inch Single-sided Double Density","/51D"); but you don't have to. If you need a comma within a value then quote the entire value. If you need a quote mark within a quoted value, double the quoted quote. eg: "5 inch, Single-sided Double Density ""SSDD""","/51D".

The user can select (click) any one of the list items and then click [Ok]. At that point the matching value (same row, second column) will be written to "out.txt". If the user clicks [Cancel], "out.txt" will be blank.

As with "ask text ..." you can specify "-bn" or "-bd" to change the buttons to [Back] and [Next] or to [Back] and [Done].

You can also include a -r to leave the list in raw (unsorted) form.

Usage 5

Sometimes you need a filename and that is often complicated. The command prompt is great for versatility, flexability and repeatability. However, it is a pain in the neck for file paths. Windows explorer is a much easier way to select a file.

If you need to go off through multiple directories to find a path to a file, you can use:

C:\Demo>ask file "Choose the transaction spreadsheet to process." out.txt

This produces:

ask.exe file
ask.exe file

You can navigate around the directory structure to pick a specific file to process. When you've selected one and clicked [Open], the full path to that file will be written to "out.txt". If you click [Cancel] then "out.txt" will be blank.

Usage 6

If you need to choose a directory instead of a file, you can use:

C:\Demo>ask dir "Choose a directory for the report." out.txt

This produces:

ask.exe dir
ask.exe dir

Again, you can navigate around the directory structure. This time you can pick a folder / directory. If you click [Ok] the selected directory path will be written to "out.txt". If you don't select a directory or if you click [Cancel] instead, "out.txt" will be blank.

Usage Notes

As with "say.exe", you can use @file for any "ask.exe" argument. This will use the contents of file as the argument. For example:

C:\Demo>type qn6.txt
What address should the items be sent to?
(Street address only, Suburb will be next)

C:\Demo>ask text @qn6.txt out.txt

This produces:

ask.exe using file content
ask.exe using file content

"ask -help" displays this help page.