scanreach()

Purpose

Offers a scan of available parent records. This function is regarded as obsolete

Syntax

int scanreach(par_rec, child_rec, role, mapnr)

Parameters

short* par_rec

Pointer to the L field of parent record

 

short* child_rec

Pointer to the L field of child record

 

char* role

Role of child - parent index to use

 

int mapnr

Number of message map to display if initial parent record is not found

Description

The scanreach() function checks to see if the parent record of the child record exists. If it does not, this function offers a scan of the parent record on its primary key.

The parameter mapnr specifies a map to display with the function map_choose(), and should be of the form:

Press <Tab> for next, <Esc> to rekey, any other key to accept.
This function is intended for less experienced programmers. The scan is only performed in the forward direction.

scanreach() is useful when the user is inserting records that must have parent records.

To use the scanreach() function, follow the steps below:

1. Get the parent's key fields from the user. These fields are entered into the child's fields

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

while (!scanreach() && jump == TRUE)
{
/* show the parent details record */
{
if (there) /* record has been accepted */
{
...
}
else /* user has pressed escape */
...

The function scanfetch automatically updates the child's fields as necessary.

Return values

When scanreach() is first called and the parent 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. If any other key is pressed, it returns the value of the global variable there.

See also

reach(), cycle()