## 7.4 Accessing arguments

### 7.4.1 Accessing input arguments

`OZ_declareTerm(n,var)`

  Declares a new variable of type `OZ_Term` named `var`, which is initialized with the value of the `n`-th (counting starts from zero) input argument.

  In case you plan to use unification for passing output arguments, you still have to pass the logic variable with which you want to unify as input argument.

`OZ_declareDetTerm(n,var)`

  Works like `OZ_declareTerm` but additionally suspends if the input argument is a free variable.

`OZ_declareInt(n,var)`

  The function expects in input argument number `n` an Oz integer. It then declares a variable named `var` of type `int` and initializes `var` with the value of this argument. The macro raises an exception if the argument is ill typed and suspends if the argument is an unbound variable.

`OZ_declareFloat(n,var)`

  Works like `OZ_declareInt` but expectes an Oz float and declares a variable of type `double`.

`OZ_declareAtom(n,var)`

  Works like `OZ_declareInt` but expectes an Oz atom and declares a variable of type `char *`.

`OZ_declareVirtualString(n,var)`

  Works like `OZ_declareInt` but expectes an Oz virtual string and declares a variable of type `char *`.

`OZ_declareVS(n,var,len)`

  Like `OZ_declareVirtualString`, but additionally sets `len` to the size of the result.

`OZ_declareBool(n,var)`

  Declares a variable of type `int` named `var`, which is non-zero iff the `n`-th argument is equal to `true`.

The above macros always declare a new C variable and then do some checks. Therefor in C (not in C++) only one of them can be used only at the start of a new block statement. For this reason there is also a second set of macros named `OZ_set*` that expect that their second argument has already been declared. Thus in C++ you can use

> `OZ_declareAtom(0,mystring);
> OZ_declareInt(1,myint);`

whereas in plain C you have to write

> `char *mystring;
> int myint;
> OZ_setAtom(0,mystring);
> OZ_setInt(1,myint);`

### 7.4.2 Accessing output arguments

`OZ_out(n)`

  Abstract access to output argument number `n` (counting starts with 0). Should only be used for writing an output argument and never for reading. Usage is like

  > `OZ_out(3) = OZ_atom("myResult");`

  This macro should only be used in case a function returns more than one value. For returning values in the first output argument one of the functions below should be used.

`OZ_RETURN(V)`

  Returns from the C function with output value `V`. It is a macro which expands to

  > `return (OZ_out(0)=V,OZ_ENTAILED)`

For convenience we also provide the following macros:

`OZ_RETURN_INT(I)`

  Return a C integer. Expands to `OZ_RETURN(OZ_int(I))`

`OZ_RETURN_ATOM(A)`

  Return a C integer. Expands to `OZ_RETURN(OZ_atom(A))`

`OZ_RETURN_STRING(S)`

  Return a C integer. Expands to `OZ_RETURN(OZ_string(S))`

`OZ_RETURN_BOOL(X)`

  Returns `false` if X equals to 0, `true` otherwise. Expands to `OZ_RETURN((X)?OZ_true():OZ_false())`