KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method to Set the Attribute of Multiple Methods Simultaneously
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: June 4, 2015

Below is a method that can modify an attribute of multiple methods simultaneously instead of going through each method one by one. This method uses the initial part of the methods name assuming that similar functioning methods will be name similarly.

// Method: SetMethodsAttribute
// Description: Modifies a set of methods that begins with the string passed
// Parameters:
// $1 - Path of the location of the methods
// $2 - The start of the names of the methods
// $3 - Attribute to set
// $4 - Setting of the Attribute
//-----------------------------------------------------------------------

C_LONGINT($1;$path_l)
C_TEXT($2;$methodName_t)
C_LONGINT($3;$attribute_l)
C_BOOLEAN($4;$set_b)
ARRAY TEXT($methods_at;0)
C_LONGINT($count_l)

If(Count parameters=4)
  $path_l:=$1
  $methodName_t:=$2
  $attribute_l:=$3
  $set_b:=$4

  METHOD GET PATHS($path_l;$methods_at)

  For($count_l;1;Size of array($methods_at))
    If (Match regex("\\A"+$methodName_t+".?";$methods_at{$count_l})
      METHOD SET ATTRIBUTE($methods_at{$count_l};$attribute_l;$set_b)
    End if
  End for

End if


Below is an example with the following sample Methods:


Running the following code:
SetMethodsAttribute(Path project method;"Test";Attribute invisible;True)
SetMethodsAttribute(Path project method;"Test";Attribute published Web;True)


Will set the attributes which can be seen below: