input to complete

Prev Next

Function Names

input to complete

Description

This function prompts a message on the screen (asking for user input) and then expects user input for a variable. In addition, given contents can be provided which the user can complete, edit or rewrite entirely. Type and value checking can be enabled if needed, e.g. numbers only, integers with in a specific range, etc.

This function is very similar to input() except that an additional function parameter in the 1st place is available to provide the initial text contents.

Note: In batch mode, the initial text will not be used.

Call as: function

Restrictions

Indirect parameter passing is disabled.

Parameter count

1-4

Parameters

No.TypeDescription
1
input
valid types Initial contents

The intial contents will be provided after the prompt and can be completed, modified or replaed by other input. Non-string values such as numbers will be converted to strings first.

2
input
string Prompt

The prompt will be displayed before input is requested

Opt. 3
input
string Checked value type

See 2nd function parameter in input().

Default value: string
Opt. 4
code
comparison expression
:string
Validation expression

If the entered value does not match with the type, then the user will be requested to repeat the input.

This parameter is a piece of code typically found on the right-hand side of a comparison with '=' or '<>'. Single values, ranges (e.g. 3..5), multiple values separated by commas are supported. For text comparison, wildcards are supported if the string is of type softquoted string.

Default value: true (no limitations)

Return value

TypeDescription
valid types Entered value

The value entered is returned, using the appropriate type.

Examples

    a[] = input("The weather is ", "Please complete following sentence: ", string );
    echo("Entered value is : ", a[],"   The type is : ", type (a[]) );

Output

Try it yourself: Open LIB_Function_input_to_complete.b4p in B4P_Examples.zip. Decompress before use.

See also

input