Next: Creating an XSB Module
Up: Calling XSB from C
Previous: The Variable-length String Data
  Contents
  Index
The previous chapter described the low-level XSB/C interface that supports
passing the data of arbitrary complexity between XSB and C. However, in
cases when data needs to be passed into an executable XSB module by the
main C program, the following higher-level interface should suffice. (This
interface is actually implemented using macros that call the lower level
functions.) These routines can be used to construct commands and queries
into XSB's register 1, which is necessary before calling
xsb_query() or xsb_command().
- void xsb_make_vars((int) N)
-
xsb_make_vars creates a return structure of arity N
in Register 2. So this routine may called before calling any of
xsb_query, xsb_query_string, xsb_command, or
xsb_command_string if parameters are to be set to be sent to the
goal. It must be called before calling one of the
xsb_set_var_* routines can be called. N must be the number
of variables in the query that is to be evaluated.
- void xsb_set_var_int((int) Val, (int) N)
-
set_and_int sets the N field in the return
structure to the integer value Val. It is used to set the value of
the N variable in a query before calling xsb_query or
xsb_query_string. When called in XSB, the query will
have the N variable set to this value.
- void xsb_set_var_string((char *) Val, (int) N)
-
set_and_string sets the N field in the return
structure to the atom with name Val. It is used to set the
value of the N variable in a query before calling
xsb_query or xsb_query_string. When called in XSB,
the query will have the N variable set to this value.
- void xsb_set_var_float((float) Val, (int) N)
-
set_and_float sets the N field in the return
structure to the floating point number with value Val. It is
used to set the value of the N variable in a query before
calling xsb_query or xsb_query_string. When called in
XSB, the query will have the N variable set to this
value.
- void xsb_var_int((int) N)
-
xsb_var_int is called after xsb_query or
xsb_query_string returns an answer. It returns the value of the
N variable in the query as set in the returned answer.
This variable must have an integer value.
- void xsb_var_string((int) N)
-
xsb_var_string is called after xsb_query or
xsb_query_string returns an answer. It returns the value of the
N variable in the query as set in the returned answer.
This variable must have an atom value.
- void xsb_var_float((int) N)
-
xsb_var_float is called after xsb_query or
xsb_query_string returns an answer. It returns the value of the
N variable in the query as set in the returned answer.
This variable must have an floating point value.
Next: Creating an XSB Module
Up: Calling XSB from C
Previous: The Variable-length String Data
  Contents
  Index
Baoqiu Cui
2000-04-23