PROMPT

From Liberty BASIC Family
Revision as of 14:25, 14 September 2020 by StPendl (talk | contribs) (Text replacement - "Building Blocks Categories" to "Building Blocks")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

Provides a pre-made dialog window with a text-box to capture user's response. The user responds to the "string expression" message. The response is stored in "responseVar$".

Syntax

  1. This form allows retrieval of a string value
    • prompt "string expression"; responseVar$
  2. This form allows retrieval of a numerical value
    • prompt "string expression"; responseVar
  3. This form adds a Caption to the window
    • prompt "Window Title" + chr$(13) + "string expression"; responseVar$

Hints

To show a default value in the text-box, assign a string value to responseVar$ before the PROMPT statement. (The default value can be typed over by the user, if needed.)
The response is captured and the window closed by either clicking the OK button or pressing the Enter key. Clicking Cancel returns an empty string and closes the window.

Example

' The basic PROMPT statement

prompt "Please enter your name"; name$
print "Thank you, "; name$

' The basic PROMPT statement with Caption added
prompt name$ + chr$(13) + "Enter your age"; age
print name$; ", you are "; age; " years old."

' With Caption and default response entered
msg$ = "Yes or No"
reply$ = "Yes"
prompt "Continue?" + chr$(13) + msg$; reply$
print reply$
end

Useful Procedures

' Place a useful function or sub using this keyword here