Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors


Manual Reference Pages  - attr_load (5)

NAME

attr/load - Load attribute definitions or assignments

CONTENTS

Synopsis
Description
Indirect Addressing
Error Handling
Examples
See Also
Author

SYNOPSIS

attr/load write, attribute <, write, attribute ... >

attr/load write, (![object])
attr/load write, (readattr)

DESCRIPTION

In the first synopsis form, loads attribute definitions into the named registers. The arguments are grouped in pairs of write and read.
write Register to store the next pointer in. The pointer will be taken from the next read argument.
attribute
  Register or index containing the text name of the attribute. A pointer to the attribute definition will be stored in the register named in the previous write argument. This will set the data type of the register to PSUNIT_TYPE_ATTRDEF.

If the attribute argument is a register containing the type PSUNIT_TYPE_XVALUE, then a pointer to the attribute definition used by the encoded data value will be stored in the write register instead.

INDIRECT ADDRESSING

In the second and third synopsis forms, the attr/load instruction can be used with indirect addressing to read the attributes assigned to an object. This instruction does not return attribute values. To access the values you must use attr/copy (see attr_copy(5)).

First a read structure is initialised when the second argument is the object to read. The write register will now hold an attribute read structure (type PSUNIT_TYPE_READATTR). A list of attributes assigned to the object will be copied into the read structure at this time.

The read structure is then given as the readattr argument in successive calls. Each call to attr/load with readattr will return the next attribute in the write register, as a pointer to an attribute definition identified by the PSUNIT_TYPE_ATTRDEF type.

Finally use reg/clr to clear the read structure and release memory associated with it.

If an attempt is made to read beyond the end of the attribute list, a NULL value is returned in the write argument.

Note that because the read structure holds a copy of the attribute types assigned to the object, if the object is updated after the read structure has been initialised it will no longer reflect the true status of the object.

ERROR HANDLING

A runtime error is generated if a named attribute does not exist in the schema, a referenced object does not exist in the nexus or if an argument provided is the wrong type.

EXAMPLES

The following demonstrates loading multiple attribute definitions:

.main  
attr/load P0, [author],
             P1, [copyright],
             P2, [description]

reg/dump P0, P1, P2

The following code demonstrates iterating attributes:

.main  
% Initialise the read structure
attr/load P0, (PCTX)

.loop   % Read the next attribute definition attr/load P1, (P0)
% Exit loop if no attributes remain reg/jmpeq &[.loop_end], P1, NULL
% Dump the register reg/dump P1
% Continue next iteration local/jmp &[.loop]
.loop_end   % Release the read structure and return reg/clr P0 func/rtn

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), ps_attributes(5), attr_add(5), attr_del(5), attr_mod(5), attr_mvadd(5), attr_mvdel(5), attr_mvmod(5), attr_copy(5), class_load(5), reg_clr(5),
PROSE Assembly Language at prose.sourceforge.net.

AUTHOR

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_load (5) 27 October 2009
Generated by manServer 1.07 from man5/attr_load.5 using man macros.