The INPUT Function

 

The INPUT function is the most basic method to prompt the user for input. It allows you to prompt for a Real value, an Integer value, a String, or a Window number or series. You can also include some help messages and prompts when you use the INPUT function. When using the INPUT function in a command file, you must include an @SUSPEND to suspend execution of the command file so that the user can respond to the prompt. To capture what the user enters, nest the INPUT call directly in the command which will use the user input, or define a macro or variable which will hold the user input.

 

The following is a sample command file which accepts user input:

 

! input1.dsp

message("INPUT Example","We're going to add Windows.",3) @CR

addwin(input(2,"Number of windows")) @CR

@SUSPEND("@CR")

@POP("p1",-1,-1,"Now, let's capture the user input as a variable.")

@PAUSE(5)

@UNPOP("p1")

!

! prompt here for the input

Sin_Freq = INPUT(1,"Sinewave Frequency","Enter Value between 1 and 25") @CR

@SUSPEND("@CR")

GSIN(100,.01,Sin_Freq) @CR

@pop("p1",-1,-1,"Now, let's capture the user input as a macro.")

@PAUSE(5)

@UNPOP("p1")

defmacro("UsrString",INPUT(3,"Enter Text","Text will be the Plot Label."),2) @CR

@SUSPEND("@CR")

grandom(100,.01) @CR

eval(strcat("LABEL(' ",UsrString," ')")) @CR

@RETURN