Xbasic

UI_GET_NUMBER Function

Syntax

Result_String as C = UI_GET_NUMBER(C title,C prompt[,C default_choice[,C format_string]])

Arguments

title

The title of the dialog box.

prompt

The descriptive text above the data entry field.

default_choice

Optional. Default = "". The number text that will be in the Number text box when the dialog box first appears.

format_string

Optional. Default = "". To force the entered number to follow a specific format, supply the optional Format String parameter. The format string is a sequence of special characters that dictates how you are to enter a valid text string.

L

Any upper letter

|

Any letter

#

Any digit, sign, or decimal

N

Any upper letter, digit, sign or decimal

n

Any letter, digit, sign or decimal

A

Any upper letter or digit

a

Any letter or digit

0

Any digit

&

Any character

Description

UI_GET_NUMBER() creates and displays a dialog box containing a number field. The number that you enter or change is returned as a Result String. This function is useful for obtaining a number value that conforms to a specified format. Use the VAL()function on the Result_String to get the number. Prompt user for number.

images/UI_GET_NUMBER.gif

The Result_String will be empty ("") if the Cancel button is selected.

Example 

This script plays a guessing game. The computer picks a random number from 0 to 100 and the user tries to guess it.

user_number = -1
secret_number = int(rand() *100)
while user_number <> secret_number
    user_number = val(ui_get_number("Game","What is your guess? (0-100)","0","000"))
    if user_number > secret_number then
        ui_msg_box("Game", "That number is too big.")
    elseif user_number < secret_number then
        ui_msg_box("Game", "That number is too small.")
    end if
end while
ui_beep()
ui_msg_box("Game","Congratulations! The number is:" + str(secret_number))

Limitations

Desktop applications only.

See Also