Tech Tip: Utility Method to Obtain List of All Form Object Methods
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: December 8, 2016
Below is a utility method that will generate an array of all method paths of object methods that exists.
The method will require an ON ERR CALL method to trap the error generated by METHOD GET CODE when the method does not exist.
Sample of using the method:
Sample database with one form and a few button objects with object methods generates the following result:
// Util_Form_Get_Objects_With_Methods // Returns an array of object method paths // of all object methods that exist // // Parameters: // $1 - Pointer to Array to contain list of Object Method Paths that exist C_POINTER($1;$result_p) ARRAY TEXT($arrForms_at;0) ARRAY TEXT($arrObject_at;0) C_LONGINT(err_l) C_LONGINT($formNum_l) C_LONGINT($objNum_l) C_TEXT($methPath_t) C_TEXT($code_t) $result_p:=$1 CLEAR VARIABLE($result_p->) FORM GET NAMES($arrForms_at) For ($formNum_l;1;Size of array($arrForms_at)) FORM LOAD($arrForms_at{$formNum_l}) FORM GET OBJECTS($arrObject_at) err_l:=0 ON ERR CALL("errMethod") For ($objNum_l;1;Size of array($arrObject_at)) $methPath_t:="[projectForm]/"+$arrForms_at{$formNum_l}+"/" $methPath_t:=$methPath_t+$arrObject_at{$objNum_l} METHOD GET CODE($methPath_t;$code_t) If (err_l=0) APPEND TO ARRAY($result_p->;$methPath_t) End if End for ON ERR CALL("") FORM UNLOAD End for |
The method will require an ON ERR CALL method to trap the error generated by METHOD GET CODE when the method does not exist.
C_LONGINT(err_l) err_l:=1 |
Sample of using the method:
ARRAY TEXT($list_at;0) Util_Form_Get_Objects_With_Methods (->$list_at) TRACE |
Sample database with one form and a few button objects with object methods generates the following result:
