BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Programming BEA Tuxedo ATMI Applications Using FML   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents

 


Boolean Functions

The following sections describe the various functions that take Boolean expressions as arguments.

Fboolco and Fvboolco

Fboolco compiles a Boolean expression for FML and returns a pointer to an evaluation tree:

char *
Fboolco(char *expression)

Here *expression is a pointer to an expression to be compiled. This function fails if any of the following field types is used: FLD_PTR, FLD_FML32, or FLD_VIEW32. If one of these field types is encountered, Ferror is set to FEBADOP.

Fvboolco compiles a Boolean expression for a VIEW and returns a pointer to an evaluation tree:

char *
Fvboolco(char *expression, char *viewname)

Here *expression is a pointer to an expression to be compiled, and *viewname is a pointer to the view name for which the fields are evaluated.

Space is allocated using malloc(3) to hold the evaluation tree. For example, the following code compiles a Boolean expression that checks whether the FIRSTNAME field is in the buffer, whether it begins with `J' and ends with `n' (such as "John" or "Joan"), and whether the SEX field is equal to `M'.

#include "<stdio.h>"
#include "fml.h"
extern char *Fboolco;
char *tree;
. . .
if((tree=Fboolco("FIRSTNAME %% 'J.*n' && SEX == 'M'")) == NULL)
F_error("pgm_name");

The first and second characters of the tree array form the least significant byte and the most significant byte, respectively, of an unsigned 16-bit quantity that gives the length, in bytes, of the entire array. This value is useful for copying or otherwise manipulating the array.

Because the evaluation tree produced by Fboolco is used by the Boolean functions described in the following sections, it is not necessary to recompile the expression constantly.

Use the free(3) function to free the space allocated to an evaluation tree when the Boolean expression will no longer be used. Compiling many Boolean expressions without freeing the evaluation tree when it is no longer needed may cause a program to run out of data space.

For more information, refer to Fboolco, Fboolco32, Fvboolco, Fvboolco32(3fml) in the BEA Tuxedo ATMI FML Function Reference.

Fboolpr and Fvboolpr

Fboolpr prints a compiled expression to the specified file stream. The expression is fully parenthesized, as it was parsed (as indicated by the evaluation tree).

void
Fboolpr(char *tree, FILE *iop)

Here:

Fvboolpr prints a compiled expression to the specified file stream.

void
Fvboolpr(char *tree, FILE *iop, char *viewname)

Here:

This function is useful for debugging.

Executing Fboolpr on the expression compiled above produces the following results:

(((FIRSTNAME[0]) %% ('J.*n')) && ((SEX[0]) == ('M')))

For more information, refer to Fboolpr, Fboolpr32, Fvboolpr, Fvboolpr32(3fml) in the BEA Tuxedo ATMI FML Function Reference.

Fboolev and Ffloatev, Fvboolev and Fvfloatev

These functions evaluate a fielded buffer against a Boolean expression.

int Fboolev(FBFR *fbfr,char *tree)
double Ffloatev(FBFR *
fbfr,char *tree)

Here:

The VIEW equivalents are as follows:

int
Fvboolev(FBFR *fbfr,char *tree,char *viewname)
double
Fvfloatev(FBFR *fbfr,char *tree,char *viewname)

Fboolev returns true (1) if the fielded buffer matches the Boolean conditions specified in the evaluation tree. This function does not change either the fielded buffer or the evaluation tree. Using the evaluation tree compiled above, the following code prints "Buffer selected":

#include <stdio.h>
#include "fml.h"
#include "fldtbl.h"
FBFR *fbfr;
. . .
Fchg(fbfr,FIRSTNAME,0,"John",0);
Fchg(fbfr,SEX,0,"M",0);
if(Fboolev(fbfr,tree) > 0)
fprintf(stderr,"Buffer selected\n");
else
fprintf(stderr,"Buffer not selected\n");

Ffloatev and Ffloatev32 are similar to Fboolev, but return the value of the expression as a double. For example, the following code prints "6.6":

#include <stdio.h>
#include "fml.h"
FBFR *fbfr;
. . .
main() {
char *Fboolco;
char *tree;
double Ffloatev;
if (tree=Fboolco("3.3+3.3")) {
printf("%lf",Ffloatev(fbfr,tree));
}
}

If Fboolev is used instead of Ffloatev in the previous example, a 1 is printed.

For more information, refer to Fboolev, Fboolev32, Fvboolev, Fvboolev32(3fml) and Ffloatev, Ffloatev32, Fvfloatev, Fvfloatev32(3fml) in the BEA Tuxedo ATMI FML Function Reference.

 

back to top previous page next page