Tech Tip: Utility method to count the number of properties found in a C_Object
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: October 19, 2016
Here is a simple utility method that can be used to count the number of properties found within a C_Object:
// UTIL_OB_COUNT C_OBJECT($1) C_LONGINT($0) If (Count parameters=1) ARRAY TEXT($tmp_array;0) OB GET PROPERTY NAMES($1;$tmp_array) $0:=Size of array($tmp_array) Else $0:=-1 End if |
If the method above is saved as UTIL_OB_COUNT it could be used like this:
C_OBJECT($ob) OB SET($ob;"a";"a") OB SET($ob;"b";"a") OB SET($ob;"c";"a") alert(String(UTIL_OB_COUNT($ob))) // returns 3 |