Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors
attr/direct - Copy values from one attribute to another
Synopsis
Description
Error Handling
Examples
See Also
Author
attr/direct ![target], targetattr, ![object], attribute
Performs a direct copy of attribute values from one object to another, overwriting the target attribute if it already exists.
Copies the value or values assigned to the attribute identified by the attribute argument from the specified source object, and stores the value(s) in the attribute identified by the targetattr argument in the target object. Note that if targetattr already exists, then the existing value(s) will be overwritten, otherwise the attribute will be newly assigned.
The targetattr and attribute arguments may be the text name of the attributes, or registers pointing to the attribute definition obtained using attr/load (the register will hold the type PSUNIT_TYPE_ATTRDEF).
If the targetattr and attribute arguments refer to the same attribute type (or the attribute data is encoded using the same syntax), then the underlying copy operation will clone the data retaining the original encoding. If they refer to different attribute types and syntax, then the data will be cloned via a byte string representation.
Because the attr/direct instruction has no way of signalling an empty (or NULL) attribute via a register, an AttributeEmpty error will be generated if the source attribute does not possess a value to be copied.
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, if an argument provided is the wrong type or if the source attribute has an empty (NULL) value.
The following demonstrates using attr/direct to copy from the standard input I/O stream and write to standard output one line at a time:
.main % Initialise registers reg/load P0, ![.prose.sys.io] attr/load P1, [psStreamIn] attr/load P2, [psStreamOut]
% Prepare to catch error error/jmp &[.trap], ![.prose.error.sys.AttributeEmpty]
.loop % Copy from input, write to output attr/direct P0, P2, P0, P1 local/jmp &[.loop]
.trap % Trap called when standard input is exhausted error/clr func/rtn
pal_commands(5), pal_registers(5), pal_indices(5), ps_attributes(5), ps_errortypes(5), attr_copy(5), attr_load(5),
PROSE Assembly Language at prose.sourceforge.net.
Copyright (c) 2002-2009 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_direct (5) | 23 October 2009 |