next up previous contents index
Next: Additional expression evaluators Up: Expression evaluator Previous: Speed considerations   Contents   Index

Numerical expressions as arguments

The functions

int convert_int(char *, flow_data *);

double convert_float(char *, flow_data *) ;

of the library can be used to parse numeric arguments. For instance if the command Xcom3 corresponding to the function

int Xcom3_cmd(int argc, char* argv[]);

needs an argument which is an integer, the function Xcom3_cmd should contain something like

    int  n;
    flow_data *flow_interp;
    flow_interp = (flow_data *) argv[-1];
    n  =  convert_int(argv[1], flow_interp);

In this argument the argument argv[1] will be sent to the expression evaluator and converted into a double precision number. Here flow_interp is a pointer to the flow_data structure corresponding to the running thread (cf. 10.4). The function convert_int will send the string of characters to the expression evaluator and return the integer part of the evaluation of this string. The function convert_float can be used to evaluate real arguments. This allows instructions like

- interpcom -> Xcom3 i+2

for instance.