Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors
attr/index - Copy attribute value as index
Synopsis
Description
Error Handling
Examples
See Also
Author
attr/index write, ![object], attribute
attr/index write, xvalue
In the first synopsis form, transforms the value from the specified attribute assigned to the named object into a raw index (32-bit unsigned integer), storing the result in the write register. The register will then hold the type PSUNIT_TYPE_RAWIDX.
In the second synopsis form, takes a PSUNIT_TYPE_XVALUE argument, transforming the value into a raw index, storing the result in the write register.
The attribute argument may be the text name of the attribute, or a register pointing to the attribute definition obtained using attr/load (the register will hold the type PSUNIT_TYPE_ATTRDEF).
If the attribute has more than one value associated with it, a NULL will be returned in the write argument instead. In this case, you must use the attr/copy instruction instead to iterate the values. See attr_copy(5).
The attribute value may already be stored as an index, e.g. by using the psIndex attribute, or it may be stored in another numeric format that can be converted into a raw index. It may also be stored as a text string. If stored as text, it will be converted to an integer using base 10 (decimal) unless the text begins 0x, which will change the conversion to base 16 (hexadecimal), or just 0 for base 8 (octal).
If your intention is to read attribute values so that they may be written to other attributes or objects, consider using the attr/direct or obj/clone instructions instead, which may be more suited to your needs and will be a generally more efficient way of copying attributes around.
A runtime error is generated if a named attribute does not exist in the schema or is not assigned to the object, a referenced object does not exist in the nexus or if an argument provided is the wrong type.
The following demonstrates transferring a raw index from a local variable called i into a register:
.main % Initialise the local variable attr/load P8, [psIndex] var/local P0, P8, [i], #253
% Copy the value into a register attr/index P1, P0, P8
pal_commands(5), pal_registers(5), pal_indices(5), ps_attributes(5), attr_copy(5), attr_direct(5), obj_clone(5), attr_load(5), reg_conv(5), attr_addr(5),
PROSE Assembly Language at prose.sourceforge.net.
Copyright (c) 2002-2013 Mark R. Bannister <cambridge@users.sourceforge.net>.
This is free software and can be downloaded from prose.sourceforge.net; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PAL 1.0 | attr_index (5) | 26 January 2013 |