scanftch()

Purpose

Offers an approximate match with scan. This function is regarded as obsolete

Syntax

int scanftch(dp4rec, index, role, mapnr)

Parameters

short* dp4rec

Pointer to data record

 

short* index

Pointer to index record on dp4rec

 

char* role

Role name of index to use

 

int mapnr

Number of map to display for user action

Description

The function scanftch() is similar to the scanreach() function and is also intended for less experienced programmers.

This function can be used when the user is entering the value of key fields and is not required to key exactly. It fetches a record with the given secondary key if one exists. If one does not exist, it offers a scan on the specified index.

The parameter mapnr specifies a map that is used to get the user response with a call to the function map_choose(), and should be of the form:

Press <Tab> for next, <Esc> to rekey, any other key to accept
To use the scanftch() function, follow the steps below:

1. Get the key fields from the user. Use a different copy of the main record, else other fields entered by the user will be overwritten

2. Call the function scanftch() as in the example skeleton below:

while (!scanftch(...) && jump == TRUE)
{
/* show the current details record */
}
if (there) /* record has been accepted */
{
...
/* copy key fields into main record */
}
else /* user has pressed escape re-enter fields */
...

You should only use the function scanftch() if there are records for it to scan through.

Return values

When scanftch() is first called and the record does not exist, the global variable jump is set to TRUE and FALSE is returned.

During subsequent calls while <Tab> is pressed it returns FALSE. If <Esc> is pressed it returns FALSE and resets the global variable jump to FALSE. For any other key it returns the value of the global variable there.

See also

scanreach()