[Next] [Previous] [Up] [Top] [Contents] [Index]

11.3 Script Utilities

11.3.2 Token Values

	typedef struct TokenValue {
		union {
			char		*string;
			EntryRef		*ref;
			float		number;
		} result;
		char		shouldFree;	
		char		flags;	
		TokAddrRec		*address;		/* For internal use only						 */
		TokInfo		info;	
	} TokenValue;

The TokenValue struct is used to hold a token value resolved from a script expression. TokenValues are used in arrays, which are returned by routines which also take the address of an integer to fill with the array length. TokenValue arrays have to be freed - using FreeToks() - when it is no longer needed. You should never create a TokenValue structure directly, but ExpandTokenValueList() and its variants can be used to generate a new array and modify it.

The flags field of a TokenValue identifies the type of value stored in the result union; it will be one of string_tok_info, reference_tok_info, or number_tok_info; the token value will then be found in result.string, result.ref, or result.number, respectively.

If a TokenValue array is obtained from GetToks(), the values are guaranteed to be strings. Similarly, GetRefs() guarantees references. Some other functions may return mixed types.

TokenValue routines should be used to read multiple tokens from an entry. This is more efficient than looping with GetATok(), and may also yeild different results if the tokens are derived from a side-effect expression.

PSYX Programmer's Manual - 24 AUG 95
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with CERN WebMaker