Difference between revisions of "AMEMBERS()"

From Lianjapedia
Jump to: navigation, search
m (Text replace - "Recital" to "Lianja")
(See Also)
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to load the properties of an object into an array
 
Function to load the properties of an object into an array
 
  
 
==Syntax==
 
==Syntax==
AMEMBERS(<array-name>,<object-ref>])
+
AMEMBERS(<array-name>, <object-ref>|<class> [,1])
 
+
  
 
==See Also==
 
==See Also==
[[ACLASS()]], [[ADDPROPERTY()]], [[CLASS]], [[CLASS - Methods]], [[CLASS - Parameters]], [[CLASS - Properties]], [[CLASS - Scoping]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[LIST CLASSES]], [[LOADOBJECT()]], [[METHOD]], [[NEWOBJECT()]], [[OBJECT()]], [[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.
  
 +
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">
class myclass
+
proc page1_section1_field1_click()
  property last_name
+
// Object browser
  property first_name
+
aselobj(refs)
  property email
+
endclass
+
  
omyclass = new myclass()
+
for i = 1 to 5
dialog box str(amembers(myarray,omyclass))  && displays 3
+
if type('refs[&i]') <> 'O'
display memory      && shows the array contents
+
loop
</code>
+
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>
  
==Products==
 
Lianja, Lianja Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Objects]]
 
[[Category:Objects]]
[[Category:Objects Functions]]
+
[[Category:Lianja v7.0]]

Latest revision as of 02:25, 26 January 2022

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:

  1. Name
  2. 'Property' | 'Method'
  3. Data type
  4. 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