Difference between revisions of "AMEMBERS()"
Yvonne.milne (Talk | contribs) (→Syntax) |
Barrymavin (Talk | contribs) (→See Also) |
||
(6 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
==Syntax== | ==Syntax== | ||
− | AMEMBERS(<array-name>,<object-ref>) | + | AMEMBERS(<array-name>, <object-ref>|<class> [,1]) |
==See Also== | ==See Also== | ||
− | [[ACLASS()]], [[ADDPROPERTY()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[NEWOBJECT()]], [[OBJECT()]], [[PEMSTATUS()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]] | + | [[ACLASS()]], [[ADDPROPERTY()]], [[ASELOBJ()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[NEWOBJECT()]], [[OBJECT()]], [[PEMSTATUS()]], [[PRINT_HTML()]], [[PRINT_JSON()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[TOARRAY()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[WITH]] |
==Description== | ==Description== | ||
− | The AMEMBERS() function is used to load the names of the properties of the specified object into an array and return the number of properties loaded (and hence the number of array elements). | + | The AMEMBERS() function is used to load the names of the properties of the specified object or class (class from v7.0) into an array and return the number of properties loaded (and hence the number of array elements). |
The <array-name> array will be created if it does not already exist. | The <array-name> array will be created if it does not already exist. | ||
− | Note: AMEMBERS() is | + | If the optional third parameter (1) is specified, the array will be 2-dimensional with the following 4 columns: |
+ | |||
+ | # Name | ||
+ | # 'Property' | 'Method' | ||
+ | # Data type | ||
+ | # Value | ||
+ | |||
+ | Note: AMEMBERS() is supported for the [[:Category:Framework Classes|UI Framework Classes]] from v7.0. | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | proc page1_section1_field1_click() | |
− | + | // Object browser | |
− | + | aselobj(refs) | |
− | + | ||
+ | for i = 1 to 5 | ||
+ | if type('refs[&i]') <> 'O' | ||
+ | loop | ||
+ | endif | ||
− | + | release props | |
− | + | amembers(props, refs[&i], 1) | |
− | + | select 0 | |
− | + | create table if not exists _amembers (name char(32), type char(20), datatype char(20), value char(255)) | |
+ | if !used('_amembers') | ||
+ | use _amembers | ||
+ | else | ||
+ | select _amembers | ||
+ | endif | ||
+ | zap | ||
+ | append from array props | ||
+ | goto top | ||
+ | browse | ||
+ | endfor | ||
+ | endproc | ||
</code> | </code> | ||
Line 31: | Line 53: | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Category:Objects]] | [[Category:Objects]] | ||
+ | [[Category:Lianja v7.0]] |
Latest revision as of 02:25, 26 January 2022
Contents
Purpose
Function to load the properties of an object into an array
Syntax
AMEMBERS(<array-name>, <object-ref>|<class> [,1])
See Also
ACLASS(), ADDPROPERTY(), ASELOBJ(), COMPOBJ(), CREATEOBJECT(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, LIST CLASSES, LOADOBJECT(), NEWOBJECT(), OBJECT(), PEMSTATUS(), PRINT_HTML(), PRINT_JSON(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), TOARRAY(), SAVEOBJECT(), SQL SELECT, WITH
Description
The AMEMBERS() function is used to load the names of the properties of the specified object or class (class from v7.0) into an array and return the number of properties loaded (and hence the number of array elements).
The <array-name> array will be created if it does not already exist.
If the optional third parameter (1) is specified, the array will be 2-dimensional with the following 4 columns:
- Name
- 'Property' | 'Method'
- Data type
- Value
Note: AMEMBERS() is supported for the UI Framework Classes from v7.0.
Example
proc page1_section1_field1_click() // Object browser aselobj(refs) for i = 1 to 5 if type('refs[&i]') <> 'O' loop endif release props amembers(props, refs[&i], 1) select 0 create table if not exists _amembers (name char(32), type char(20), datatype char(20), value char(255)) if !used('_amembers') use _amembers else select _amembers endif zap append from array props goto top browse endfor endproc