askf_password()

Purpose

Obtains the password from the user

Old name

#define scrn_password askf_password

Syntax

int askf_password(mapnr, fieldnr, password)

Parameters

int mapnr

Number of map containing the field

 

int fieldnr

Field from which to get password

 

char* password

Pointer to an array to hold the entered password

Description

The askf_password() function is used to obtain a character string from the user which normally represents a password that must not be echoed on the screen. Instead the '#' character is echoed as a guide to the number of characters entered.

On first entering the function, a row of dots is displayed, one per character, in the field. If the <Backspace> key is pressed, the display is cleared and the input restarts from the beginning of the field. (In version 4.6xx the display is initially blank and asterisks are used instead)

The map must already be on the screen when the function is called.

Earlier versions of this function had a restriction on the number of characters that the field could contain. This has now been removed.

Return values

Returns the value of the global variable abort_code which is zero or ESCAPE if the user has pressed the <Esc> key

Example

/*
C Functions Reference Manual
----------------------------
Filename: ASKF_PAS.C
Example: askf_password
Purpose: Program gets a password before user can
proceed
*/

/*#db salesord
#c
#end*/
#include "dp4.h"
#include "askf_pas.h"
/* generate this file by running LIBMAKE */

boolean valid_password(char *);
void start_prog(void);

void process()
{
char password[8];
map_draw(1, RETAIN);
for (;;)
{
if (askf_password(1, 1, password))
/* if Escape pressed */
dp4_halt(1); /* exit the program */
if (valid_password(password))
/* check password valid */
break;
}
start_prog(); /* start main part of program */
}
/* dummy functions follow */
boolean valid_password(char * password)
{
/* checks password is valid */
return TRUE;
}
void start_prog()
{
/* starts main part of program */
return;
}