AMEMBERS()

From Lianjapedia
Jump to: navigation, search

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