Tech Tip: Utility Method To Get Command Number
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: December 10, 2015
Below is a utility method that returns the 4D Command number of the string passed.
// Method: UtilGetCommandNum // Parameters: // $1 - String Command Name // Output: // $0 = -1 If unable to find command // $0 = {Positive Number} //----------------------------------------------------------------------- C_TEXT($1;$cmdName_t) C_LONGINT($cmdID_l) C_LONGINT($0) $cmdName_t:=$1 $cmdID_l:=-1 Repeat $cmdID_l:=$cmdID_l+1 If ($cmdName_t=Command name($cmdID_l)) $0:=$cmdID_l OK:=0 End if Until (OK=0) |
Example of using the command:
C_LONGINT($res1_l;$res2_l;$res3_l) $res1_l:=UtilGetCommandNum("String") $res2_l:=UtilGetCommandNum("All Records") $res3_l:=UtilGetCommandNum("SuperMan") |
Results:
$res1_l=10
$res2_l=47
$res3_l=-1
Related:
Tech Tip: Where to find 4D Command numbers