Next Previous Contents

101. SLadd_intrinsic_variable


Add an intrinsic variable to the interpreter


int SLadd_intrinsic_variable (name, addr, type, rdonly)

    char *name
    VOID_STAR type
    unsigned char type
    int rdonly

The SLadd_intrinsic_variable function adds an intrinsic variable called name to the interpeter. The second parameter addr specifies the address of the variable (cast to VOID_STAR). The third parameter, type, specifies the data type of the variable. If the fourth parameter, rdonly, is non-zero, the variable will interpreted by the interpreter as read-only.

If successful, SLadd_intrinsic_variable returns zero, otherwise it returns -1.


Suppose that My_Global_Int is a global variable (at least not a local one):

    int My_Global_Int;
It can be added to the interpreter via the function call
    if (-1 == SLadd_intrinsic_variable ("MyGlobalInt",
                                        SLANG_INT_TYPE, 0))
      exit (1);

The current implementation requires all pointer type intrinsic variables to be read-only. For example,

    char *My_Global_String;
is of type SLANG_STRING_TYPE, and must be declared as read-only. Finally, not that
   char My_Global_Char_Buf[256];
is not a SLANG_STRING_TYPE object. This difference is very important because internally the interpreter dereferences the address passed to it to get to the value of the variable.
See Also

SLadd_intrinsic_function, SLadd_intrinsic_array


Next Previous Contents