Next Previous Contents

4. Dialog and Message Functions

This chapter describes some functions which are useful if you want to interact with the user.

4.1 get_response

Usage

Integer get_response (String choices, String prompt)

Description

This function will prompt the user for a single character using the prompt as specifed by the second parameter. The first parameter, choices, specified the characters that will be accepted. Any character in the prompt string that is preceeded by \001 will be given the `response_char' color.

Example

The following:

       rsp = get_response ("yYnN", "Are you hungry? \001Yes, \001No");
will return one of the four characters y, Y, n, or N to the variable rsp.

See Also

get_yes_no_cancel, set_color, get_select_box_response

4.2 get_select_box_response

Usage

Integer get_select_box_response (title, item_1, ..., n_items)

Description

This function pops a selection box and queries the user for a response. An integer is returned which indicates the user's choice.

Example

       variable rsp = get_select_box_response (
                         "Pick a number:",
                         "one", "two", "three", "four",
                         4);
       message (sprintf ("You chose %d", rsp));

See Also

read_mini, message, get_yes_no_cancel, get_response, select_list_box

4.3 get_yes_no_cancel

Usage

Integer get_yes_no_cancel (str)

Description

This function displays str in the minibuffer after concatenating "? [Y]-es, N-o, C-ancel" to it. It then awaits user input and returns:

        1 if yes
        0 if no
       -1 if cancel

Notes

If a % character is to appear, it must be doubled.

See Also

get_select_box_response, getkey, read_mini, select_list_box

4.4 message_now

Usage

Void message_now (String_Type s)

Description

This function displays the string s to the message area immediately.

See Also

message, vmessage, error

4.5 popup_window

Usage

Int popup_window (String title, String text)

Description

This function creates a popup window which contains the given text and uses title as its title. It returns the key that was used to exit the window.

Notes

Since slrn 0.9.7.4, this function expands TABs in the text correctly. TABs in title are not expanded and should be avoided.

See Also

select_list_box

4.6 read_mini

Usage

String read_mini (String p, String dflt, String init)

Description

This function will prompt the user for a string value using prompt p. The second parameter dfl is used to specify the default value. If the final parameter is not the empty string (""), it will be made available to the user for editing.

See Also

read_mini_filename, read_mini_no_echo, read_mini_integer, read_mini_variable, getkey, set_input_string, set_input_chars

4.7 read_mini_filename

Usage

String read_mini_filename (String p, String dflt, String init)

Description

This function works like read_mini, but allows the user to tab complete filenames.

See Also

read_mini, read_mini_variable, getkey, set_input_string, set_input_chars

4.8 read_mini_integer

Usage

Integer read_mini_integer (String p, Integer dflt)

Description

This function will prompt the user for an integer value using prompt p and taking dflt as the default.

See Also

read_mini

4.9 read_mini_no_echo

Usage

String read_mini_no_echo (String p, String dflt, String init)

Description

This function performs the same purpose as read_mini except it does not echo the entered text to the screen.

See Also

read_mini, getkey, set_input_string, set_input_chars

4.10 read_mini_variable

Usage

String read_mini_variable (String p, String dflt, String init)

Description

This function works like read_mini, but allows the user to tab complete the names of slrn's configuration variables.

See Also

read_mini, read_mini_filename, getkey, set_input_string, set_input_chars

4.11 select_list_box

Usage

String_Type select_list_box (title, s_1, ... s_n, n, active_n)

    String_Type title, s_1, ... s_n
    Int_Type n, active_n

Description

This purpose of this function is to present a list of n strings, specified by the s_1, ... s_n parameters to the user and have the user select one. The user interface for this operation is that of a box of strings. The title of the box is specified by the title parameter. The active_n parameter specifies which string is to be the default selection. It returns the string selected by the user.

See Also

get_select_box_response, get_response

4.12 set_input_chars

Usage

Void set_input_chars (String val)

Description

This function may be used to set the character that will be returned by the next prompt for single character input in the minibuffer. This is the type of input that get_response solicits.

Example

       set_input_chars ("y");
       if ('y' == get_yes_no_cancel ("Really Quit"))
         quit (0);

See Also

set_input_string, get_response, get_yes_no_cancel

4.13 set_input_string

Usage

Void set_input_string (String val)

Description

This function may be used to set the string that will be returned by the next prompt for input in the minibuffer. One can set the value returned for the next n prompts by separating the values by \n characters.

Example

The code

       variable a, b;
       set_input_string ("Apple\nOrange");
       a = read_mini ("Enter Fruit", "", "");
       b = read_mini ("Enter another Fruit", "", "");
will result in a having the value Apple and b having the value Orange.

See Also

read_mini, set_input_chars


Next Previous Contents