Previous Up Next

10.2.2  Input

You can prompt the user to enter a value for a variable with the input (or Input command). If you enter

input(a)

the the user will be given a box where they can enter a value for the variable a. There will be a prompt indicating the name of the variable; if you want a more descriptive prompt, you can give input a string argument before the variable name.

input("Set a to the value: ",a)

will prompt the user with "Set a to the value: " before the input box.

If the value that you enter for input is a string, it should be between quotes. If you want the user to enter a string without having to use the quotes, you can use InputStr or textinput, which will assume the input will be a string and so the user won’t need to use quotes.

The output (or Output) command can take strings (or variables representing strings) as arguments and can be used to add information to the input window. For example, if you enter

input(output("Calculate p(a)"),"polynomial",p,"value",a)

then you will get a window with a box containing

Calculate p(a)

followed by the prompts for p and a.


Previous Up Next