Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

END of Key Segment

ENDSEG is used for searching the trailing end of a key segment. ENDSEG automatically right justifies the string, filling the left-hand portion of the segment with the value PADDING, (#define PADDING ‘’ ), then flipping the value.

Note: This segment mode supports STRING field types ONLY.

The following example contains a duplicate allowed index over customer name. The code prompts the user to enter a customer name for the search. Since the index uses the ENDSEG segment mode, just the last few letters may be entered. For example, a target of ‘son’ would retrieve ‘Anderson’ and ‘Emerson’ from the following list of names: Adams, Anderson, Barrington, Emerson.

#define c_rec_len 4*namebuf+4

#define namebuf 30

TEXT inpbuf[namebuf], target[namebuf+sizeof(long)];

COUNT tar_length;

struct {

TEXT ch_name[namebuf]; /* customer name */

TEXT child1[namebuf]; /* customer name */

TEXT child2[namebuf]; /* customer name */

TEXT child3[namebuf]; /* customer name */

LONG ch_num; /* customer number */

} childimage;

ISEG segments[] = {

{0,30,ENDSEG},}; /* first 30 bytes of ch_name */

IIDX indices[] = { /* Duplicate allowed index, therefore key length = 30+4 */

{34, 0, 1, 1, 32, 1, &segments[0], "child_key"}};

IFIL file[] =

{"child", 5, c_rec_len, 4096, 1, 1, 4096, 1,

&indices[0], "ch_name","child3",0};

memset(&childimage,' ',(4*namebuf)); /*pad strings */

memset(target,' ',namebuf);

memset(inpbuf,' ',namebuf);

printf("\n\rEnter name to retrieve by ENDSEG: ");



tar_length = strlen(target);

TransformKey(6,target); /* Optional if automatic */

/* transformations are used by calling an extended */

/* initialization call such as INTISAMX */

if (error = FRSSET(6,target,&childimage,tar_length))

printf("Error on FRSSET(), error = %d decimal",error);

else { /* else if not error, print results */

printf("\nSuccessful retrieval for the ENDSEG INDEX ");

printf("\n\nName: %s",&childimage.ch_name);