Tech Tip: Utility Method to Search Methods Based on Their Properties
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: July 6, 2021
This is a utility method to search for project methods based on their properties. This can be used to find all of the project methods with the "Execute on Server" property selected for instance.
Parameters:
- $1 (Longint) - Accepts a number 1-9 to specify the method property to search. The number corresponds with the method properties shown from top to bottom (1.Invisible, 2.Shared by component, 3.Execute on server, 4.Execution mode, 5.Web Services, 6.Published WSDL, 7.4D tags and URLS, 8.SQL, and 9.REST Server).
- $2 (Variant) - Accepts either a boolean or string for the value of the method property to search. Pass True to search for a checked property and False for unchecked. When searching Execution mode, accepts a string value ("indifferent", incapable", or "capable"). When searching REST Server, accepts string value for scope ("none", "table", "currentRecord", "currentSelection", "catalog")
- $3 (String) - This parameter is optional and only applies when searching REST Server. It accepts string value for table. Empty string ("") can be passed in $2 to only search for REST Server table.
- $0 (Object) - Returns an object containing the names and properties of all project methods that matches the specified value for the property.
//================================================================= //DESCRIPTION: Search for methods based on their properties //PARAMETERS: // - $1 (longint) : Accepts 1-9 to determine the method property to query // - $2 (boolean or string) : Accepts value of the method property to search. If 9 is passed in first parameter, this parameter accepts the scope. // - $3 (string) : OPTIONAL - Only applicable when 9 is passed in first parameter. This parameter accepts the table. Can pass empty string in second parameter to only search for matching tables // - $0 (object) : Returns an object with the found method names and their properties //================================================================= C_OBJECT($0; $o) $o:=New object If (Count parameters>=2) ARRAY TEXT($methNames; 0) ARRAY TEXT($methNames; 0) ARRAY OBJECT($methAttrib; 0) C_LONGINT($1; $query; $i) C_VARIANT($2; $value) C_TEXT($attrib) $query:=$1 $value:=$2 METHOD GET NAMES($methNames) METHOD GET ATTRIBUTES($methNames; $methAttrib) Case of : ($query=1) $attrib:="invisible" //values (boolean): True, False : ($query=2) $attrib:="shared" //values (boolean): True, False : ($query=3) $attrib:="executedOnServer" //values (boolean): True, False : ($query=4) $attrib:="preemptive" //values (string): indifferent, incapable, capable : ($query=5) $attrib:="publishedSoap" //values (boolean): True, False : ($query=6) $attrib:="publishedWsdl" //values (boolean): True, False : ($query=7) $attrib:="publishedWeb" //values (boolean): True, False : ($query=8) $attrib:="publishedSql" //values (boolean): True, False : ($query=9) $attrib:="published4DMobile" //values (string):scope : none, table, currentRecord, currentSelection, catalog / table : If (Count parameters=3) C_TEXT($3; $table) $table:=$3 End if End case Case of : ($query#9) For ($i; 1; Size of array($methAttrib)) If (Value type($methAttrib{$i}[$attrib])=Value type($value)) If ($methAttrib{$i}[$attrib]=$value) $o[$methNames{$i}]:=$methAttrib{$i} End if End if End for : ($query=9) & (Count parameters=2) For ($i; 1; Size of array($methAttrib)) If (Value type($methAttrib{$i}[$attrib].scope)=Value type($value)) If ($methAttrib{$i}[$attrib].scope=$value) $o[$methNames{$i}]:=$methAttrib{$i} End if End if End for : ($query=9) & (Count parameters=3) For ($i; 1; Size of array($methAttrib)) If ($methAttrib{$i}[$attrib].table#Null) If (Value type($methAttrib{$i}[$attrib].table)=Value type($table)) If ($methAttrib{$i}[$attrib].table=$table) If ($value="") $o[$methNames{$i}]:=$methAttrib{$i} Else If (Value type($methAttrib{$i}[$attrib].scope)=Value type($value)) If ($methAttrib{$i}[$attrib].scope=$value) $o[$methNames{$i}]:=$methAttrib{$i} End if End if End if End if End if End if End for End case End if $0:=$o |
Here is are 3 examples of calling this method. The first example searches for all of the project methods with the "Execute on Server" property selected. The second example searches for methods with the Execution mode on "indifferent". The third example searches for methods with the REST Server checked and with the "Table_1" as the table.
C_OBJECT($method_o) //Returns methods with "Execute on Server" on $method_o:=Util_QueryMethodByProperties(3; True) //Returns methods with "Execution mode" on "indifferent" $method_o:=Util_QueryMethodByProperties(4; "indifferent") //Returns methods with "REST Server" on and table as "Table_1" $method_o:=Util_QueryMethodByProperties(9; ""; "Table_1") |