Initializing help system before first use

# setunvalue

Purpose
Set the value of a union.
Synopsis
`int setunvalue(XPRMcontext ctx, XPRMunion un, int type, XPRMalltypes *value);`
Arguments

ctx | Mosel's execution context
un | Reference to a union entity
type | ID of the type of the value to assign
value | Pointer to an area where the value is stored

Return value
0 if successful, any other value indicates an error.
Further information
1. The value associated with the union is replaced by a copy of the provided value that must have a type compatible with the union (otherwise the operation fails). If the current value of the union is of the same type as the provided value then a direct assignment between the entity stored in the union and the new value is performed. Otherwise, the current value of the union is released, a new instance of the required type is created before performing a direct assignment. Note that although no implicit type conversion is performed, assigning an integer to a union compatible only with reals will succeed ( i.e. the integer value will be automatically converted to real).
2. If the provided value is also a union the assignment operation is executed on the value stored in this union, if its type is not compatible with the destination of the assignment the operation will fail. If this value is an undefined union then the destination entity will also become undefined ( i.e. the current value of the union is released and the entity returns to its initial state).
3. If the given type is 0 and the value is a NULL pointer or a reference to NULL this routine will have the same effect as calling resetunion.
Related topics
unionwrap, getunvalue.
Parent Topic Union access

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.