inpm_e()

Purpose

Inputs a menu option

Syntax

int inpm_e(data, mapnr)

Parameters

short* data

Pointer to variable containing number of map to display over the current input field

 

int mapnr

Menu map to display

Description

The inpm_e() function allows the entry of a value from a menu while the cursor is still in the main data entry map

This function replaces the old function inpm_option which also required the number of fields in the menu. It assumes that data entry processing is being done and that the function map_use() has been called to set the global variables input_map and input_field.

This function displays the menu and if the parameter data is not zero, it shows the map given by map number (mapnr + data) over the field given by the global variable input_field.

If <Space> is pressed, a choose operation is performed on the map specified by the parameter mapnr, otherwise the number or mnemonic key pressed by the user defines the value of the input data.

If the user presses a function key or a number key which has not been set up, this is equivalent to pressing <Space>.

If an option is selected, the function inpm_e() shows the map with a map number (mapnr + <value of field chosen>) over the current input field.

The parameter data is set to the option chosen.

Return values

Returns ESCAPE if the user presses <Esc>, otherwise returns 0

See also

inpm_ge()

Example

/*
C Functions Reference Manual
----------------------------
Filename: INPM_E.C
Example: inpm_e
Purpose: A version of employee entry using inpm_e
rather than askm_special
*/
/*
#db salesord
#c
#tables employee;
#end
*/
#include "dp4.h"
#include "inpm_e.h"
/* generate this file by running LIBMAKE */

/* prototypes */
void get_new_emp(void);
void init_new_emp(void);
void emp_inner(int,int*);

void process()
{
map_datamap(1);
trm_read_user();
/* only required if using Microsoft C: a bug in
the linker causes an unresolved external error
in the DP4 library */
get_new_emp();
}

void get_new_emp()
{
map_datamap(2); /* display the datamap */
init_new_emp(); /* initialise the new fields */
if (!map_get_inputs(2, 1, emp_inner, GI_GLOBALS))
rec_post_commit(&employee.l);
/* Note: in 4.42x, the flag ASK_CONFIRM should be
passed to this function. In 4.500 and onwards,
Save/Cancel buttons should be added to the map
*/
}

void init_new_emp()
/* initialise fields for a new customer */
{
/* get last customer and add 1 */
rec_fetch_main(LAST,&employee.l);
employee.employee_number++;
employee.gender[0] = 'M';
memset(&employee.date_of_birth,0,
sizeof(employee.date_of_birth));
employee.grade[0] = 'W';
WIPE(employee.name);
}

void emp_inner(m,f)
int m; int* f;{ int field_nr = *f;
switch (field_nr)
{
case 1:
inpm_c(employee.name);
break;
case 2: /* show it only */
show_h(m,2,employee.employee_number);
inpm_omit();
break;
case 4:
{
int option = employee.gender[0] ==
'M' ? 1: 2;
inpm_e(&option,6);
if (!abort_code) employee.gender[0] =
(char)((option == 1) ? 'M': 'F');
}
break;
case 5:
inpm_d(&employee.date_of_birth);
break;
case 7: /* region code choose from a menu */
{
static char grades[4] =
{'D','M','C','W'};
int option = 4;
int i = 0;
while (i < 3)
{
if (grades[i] == employee.grade[0])
option = i + 1; i++;
}
inpm_e(&option,10);
if (!abort_code)
employee.grade[0] = grades[option - 1];
}
break;
default:
inpm_omit();
break;
}
}