Tech Tip: Utility Method to Check If Command Is Deprecated
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: August 7, 2025
Starting in 20 R9, the command “Command name” can be used to check if a command is deprecated by passing the command number. This is useful for when a legacy database needs to be updated with modern commands. Below is a utility method (“isDeprecated”) to check if a command is deprecated by passing the command name as text:
#DECLARE($name : Text) var $bitInfo; $cmdNum : Integer var $cmdName : Text var $depList; $notDepList : Collection $depList:=New collection $notDepList:=New collection Repeat $cmdNum:=$cmdNum+1 $cmdName:=Command name($cmdNum; $bitInfo) If ($bitInfo ?? 1) $depList.push($cmdName) Else $notDepList.push($cmdName) End if Until (OK=0) If ($depList.indexOf($name)#-1) return True Else If ($notDepList.indexOf($name)#-1) return False Else return "Command name not found" End if End if |
Below are some example uses of the utility method:
$b1:=isDeprecated("C_BOOLEAN") // True $b2:=isDeprecated("ALERT") // False $b3:=isDeprecated("_O_PREVIOUS RECORD") // Command name not found |
If the command name is deprecated, the method returns True. If not deprecated, it returns False. If the passed name was not found as an actual command, it returns “Command name not found”.