askf_x()

Purpose

Field input functions

Old name

#define scrnx_field askf_x

Syntax

int askf_c(mapnr, fieldnr, data)
int askf_d(mapnr, fieldnr, data)
int askf_h(mapnr, fieldnr, data)
int askf_i(mapnr, fieldnr, data)
int askf_l(mapnr, fieldnr, data)
int askf_n(mapnr, fieldnr, data)
int askf_s(mapnr, fieldnr, data)
int askf_t(mapnr, fieldnr, data)
int askf_u(mapnr, fieldnr, data)
int askf_y(mapnr, fieldnr, data)

Parameters

int mapnr

Number of map containing the field

 

int fieldnr

Number of field to input data from

 

<type> data

Variable or pointer to variable in which to place input data

 

The <type> of the parameter data depends on which askf_x() function is used, as shown below. Also shown is the corresponding DP4 datatype for each of the askf_x() functions:

Function Type DP4 datatype

askf_c

char*

C

askf_d

datetype*

D

askf_h

short*

I

askf_i

int*

I

askf_l

long*

L

askf_n

double*

N

askf_s

char*

S

askf_t

timetype*

T

askf_u

char*

U

askf_y

boolean *

Y

Description

These functions are the screen input functions. The data is accepted from the screen in the position of the specified field.

These functions are generally used when there is only one field in the map, or the input sequence is fixed and previous input values cannot be corrected. If the user is allowed to cursor through the fields the scrnx_map() or inpm_x() functions should be used.

The detailed action of the askf_x() functions depends on the global variables clearfirst and jump.

The global variable clearfirst controls whether the field should appear as it does before any input, or set to the default value.

The global variable jump gives you a mechanism for skipping the remaining fields in a sequence.

The global variables clearfirst and jump are most commonly used as follows:

  • clearfirst = 0, jump = TRUE
    With these settings, the data is displayed as for a call to the corresponding show_x() function. The global variable abort_code is set to zero for the askf_x() function. The program does not stop for input from the user

  • clearfirst = 1
    In this case, the askf_x() function sets the global variable jump to FALSE. If the global variable clearfirst is 1 and the field is marked on the map as a clearfirst field, the data is set to the default on the database or zero, or if it is not a database field a blank value. The program stops for input from the user

If the value entered by the user differs from the previous value, the global variable changed is set to TRUE.

If the user presses <Tab> without altering the data, the global variable jump is set to TRUE, otherwise its value is not changed.

If the user presses <Esc>, the global variable abort_code is set to ESCAPE, otherwise it is set to zero.

The format in which the data is displayed is controlled by the global variables scrn_flags and scrnd_flags, which are initialised to the value DEFAULT. The global variables scrn_flags and scrnd_flags may take the same values as the global variables show_flags and showd_flags, as described for the show_x() functions, with the following differences:

 

Value

Meaning

 

SKIP_MISSING_FIELD

If the field does not exist then the program does not crash. A value of zero is returned

 

FUNC_KEYS

Allows the user to press one of the function keys, which will return with the global variable abort_code set to a non-zero value. In some configurations, 9 and 10 will be used for help and training mode keys and will not return a value

 

CURS_KEY

Changes the action of the <Ins>, <Del>, <Pg Up> and <Pg Dn> cursor keys. Instead of editing, they cause the function to return with the global variable abort_code set to a non-zero value

 

NULL_FORBIDDEN

Prevents the input of a null value

 

END_WITHOUT_CR

Causes input to terminate when the field is full, without the user having to press <Enter>

 

OVERTYPE_MODE

Prevents the function askf_c() destroying the existing contents of field as soon as the user presses a key

 

If the global variables scrn_flags and scrnd_flags are set to the value DEFAULT, a call to an askf_x() function will use the format flags that were set with MAPEDIT or MAPPOST.

If the global variable abort_code is set to a non-zero value on return, its numeric value can be used to determine which key was pressed. The possible values are:

 

Value

If the user pressed

 

ESCAPE
INSERT
DELETE
PAGEUP
PAGEDOWN
1,2,3,,...n

the <Esc> key
the <Ins> key
the <Del> key
the <Pg Up> key
the <Pg Dn> key
the function key <F1>, <F2>, …<Fn>

 

To input into multi-occurs fields, use the general askf() function, unless it is a character field when you can use the askf_c function.

Return values

Returns the value of the global variable abort_code

See also

scrnx_map(), inpm_x(), show_x(), scrn_flags, scrnd_flags

Example

if (!askf_c(1,2,customer.name))
{..
if (!askf_d(1,2,&order.date))
{..
if (!askf_t(1,2,&order.time))
{..
if (!askf_i(1,3,&orderline.quantity))
{..
if (!askf_l(1,3,&longdata))
{..
if (!askf_n(1,4,&material.price))
{..
if (!askf_u(1,1,customer.name))
{..
if (!askf_y(1,8,&job.complete))
{..
>