Description: Documentation

## function __get_reference

### Synopsis

Get a reference to a global object

### Usage

Ref_Type __get_reference (String_Type nm)

### Description

This function returns a reference to a global variable or function whose name is specified by nm . If no such object exists, it returns NULL , otherwise it returns a reference.

### Example

For example, consider the function:

        define runhooks (hook)
        {
           variable f;
           f = __get_reference (hook);
           if (f != NULL)
             @f ();
        }

This function could be called from another SLang function to allow customization of that function, e.g., if the function represents a mode, the hook could be called to setup keybindings for the mode.

### See also

is_defined , typeof , eval , autoload , __is_initialized , __uninitialize

## function __uninitialize

### Synopsis

Uninitialize a variable

### Usage

__uninitialize (Ref_Type x)

### Description

The __uninitialize function may be used to uninitialize the variable referenced by the parameter x .

### Example

The following two lines are equivalent:

         () = __tmp(z);
         __uninitialize (&z);

### See also

__tmp, __is_initialized

## variable _auto_declare

### Synopsis

Set automatic variable declaration mode

### Usage

Integer_Type _auto_declare

### Description

The _auto_declare may be used to have all undefined variables implicitely declared as static . If set to zero, any variable must be declared witha variable declaration before it can be used. If set to one, then any undeclared variabled will be declared as a static global variable. The _auto_declare variable is is local to each compilation unit and setting its value in one unit has no effect upon its value in other units. The value of this variable has no effect upon the variables in a function.

### Example

The following code will not compile if X not been declared:

        X = 1;

However,

        _auto_declare = 1;   % declare variables as static.
        X = 1;

is equivalent to

        static variable X = 1;

### Notes

This variable should be used sparingly and is intended primarily for interactive applications where one types SLang commands at a prompt.

## function getenv

### Synopsis

Get the value of an environment variable

### Usage

String_Type getenv(String_Type var)

### Description

The getenv function returns a string that represents the value of an environment variable var . It will return NULL if there is no environment variable whose name is given by var .

### Example

        if (NULL != getenv ("USE_COLOR"))
          {
            set_color ("normal", "white", "blue");
            set_color ("status", "black", "gray");
            USE_ANSI_COLORS = 1;
          }

### See also

putenv , strlen , is_defined

## function implements

### Synopsis

Name a private namespace

### Usage

implements (String_Type name);

### Description

The implements function may be used to name the private namespace associated with the current compilation unit. Doing so will enable access to the members of the namespace from outside the unit. The name of the global namespace is Global .

### Example

Suppose that some file t.sl contains:

         implements ("Ts_Private");
         static define message (x)
         {
            Global->vmessage ("Ts_Private message: %s", x);
         }
         message ("hello");

will produce "Ts_Private message: hello" . This message function may be accessed from outside via:

        Ts_Private->message ("hi");

### Notes

Since message is an intrinsic function, it is global and may not be redefined in the global namespace.

## function putenv

### Synopsis

Add or change an environment variable

### Usage

putenv (String_Type s)

### Description

This functions adds string s to the environment. Typically, s should of the form " name=value ". The function signals a SLang error upon failure.

### Notes

This function is not available on all systems.

### See also

getenv , sprintf