Fgetlast, Fgetlast32 - get copy of last occurrence
#include <stdio.h> #include "fml.h" int Fgetlast(FBFR *fbfr, FLDID fieldid, FLDOCC *oc, char *value, FLDLEN *maxlen) #include "fml32.h" int Fgetlast32(FBFR32 *fbfr, FLDID32 fieldid, FLDOCC32 *oc, char *value, FLDLEN32 *maxlen)
Fgetlast() is used to retrieve both the value and occurrence number of the last occurrence of the field identified by fieldid. fbfr is a pointer to a fielded buffer. In order to return the occurrence number of the last field, the occurrence argument, oc, is a pointer-to-integer, not an integer.
The caller provides Fgetlast(\|) with a pointer to a private buffer, loc, as well as the length of the buffer, *maxlen, and the length of the field is returned in *maxlen. If maxlen is NULL when the function is called, then it is assumed that the buffer for the field value is big enough to contain the field value and the length of the value is not returned. If loc is NULL, the value is not returned. If oc is NULL, the occurrence is not returned.
In the SYNOPSIS
section above the value argument to Fgetlast(\|) is described as a character pointer data type (char * in C). Technically, this describes only one particular kind of value passable to Fgetlast(\|). In fact, the type of the value argument should be a pointer to an object of the same type as the type of the fielded-buffer representation of the field being retrieved. For example, if the field is stored in the buffer as type FLD_LONG, then value should be of type pointer-to-long (long * in C). Similarly, if the field is stored as FLD_SHORT, then value should be of type pointer-to-short (short * in C). The important thing is that Fgetlast(\|) assumes that the object pointed to by value has the same type as the stored type of the field being retrieved.
Fgetlast32 is used with 32-bit FML.
This function returns \-1 on error and sets Ferror to indicate the error condition.
Under the following conditions, Fgetlast() fails and sets Ferror to:
Fintro(3fml),
Fget(3fml),
Fgetalloc(3fml),
Fgets(3fml),
Fgetsa(3fml)