4D v14.3

Command name

Home

 
4D v14.3
Command name

Command name 


 

Command name ( command ) -> Function result 
Parameter Type   Description
command  Longint in Command number
Function result  String in Localized command name

The Command name command returns the literal name of the command whose command number you pass in command.

4D integrates a dynamic translation of the keywords, constants, and command names used in your methods. For example, if you use the English version of 4D, you write:

 DEFAULT TABLE([MyTable])
 ALL RECORDS([MyTable])

This same code, reopened with the French version of 4D, will read:

 TABLE PAR DEFAUT([MyTable])
 TOUT SELECTIONNER([MyTable])

However, 4D also includes a unique feature, the EXECUTE FORMULA command, which allows you to build code on the fly and then execute this code, even though the database is compiled.

The example code, written with EXECUTE FORMULA statements in English, looks like:

 EXECUTE FORMULA("DEFAULT TABLE([MyTable])")
 EXECUTE FORMULA("ALL RECORDS([MyTable])")

This same code, reopened with the French version of 4D, will then read:

 EXECUTER FORMULE("DEFAULT TABLE([MyTable])")
 EXECUTER FORMULE("ALL RECORDS([MyTable])")

4D automatically translates EXECUTE FORMULA (English) to EXECUTER FORMULE (French), but cannot translate the text statement you passed to the command.

If you use the EXECUTE FORMULA command in your application, you can use Command name to eliminate international localization issues for statements you execute in this way, and thus make your statements independent of language. The example code becomes:

 EXECUTE FORMULA(Command name(46)+"([MyTable])")
 EXECUTE FORMULA(Command name(47)+"([MyTable])")

With a French version of 4D, this code will read:

 EXECUTER FORMULE(Nom commande(46)+"([MyTable])")
 EXECUTER FORMULE(Nom commande(47)+"([MyTable])")

Note: The number of each command is provided in the Properties area of the command documentation page.

The Command name command sets the OK variable to 1 if command corresponds to an existing command number, and to 0 otherwise. Note, however, that some existing commands have been disabled, in which case Command name returns an empty string (see last example).

For all the tables of your database, you have a form called “INPUT FORM” used for standard data entry in each table. Then, you want to add a generic project method that will set this form as the current input form for the table whose pointer or name you pass. You write:

  ` STANDARD INPUT FORM project method
  ` STANDARD INPUT FORM ( Pointer {; String })
  ` STANDARD INPUT FORM ( ->Table {; TableName })
 C_POINTER($1)
 C_STRING(31;$2)
 
 If(Count parameters>=2)
    EXECUTE FORMULA(Command name(55)+"(["+$2+"];"+Char(Double quote)+"INPUT FORM"+Char(Double quote)+")")
 Else
    If(Count parameters>=1)
       FORM SET INPUT($1->;"INPUT FORM")
    End if
 End if

After this project method has been added to your database, you write:

 STANDARD INPUT FORM(->[Employees])
 STANDARD INPUT FORM("Employees")

Note: Usually, it is better to use pointers when writing generic routines. First, the code will run compiled if the database is compiled. Then, as in the previous example, your code can cease to work correctly if you rename the table. However, in certain cases, using EXECUTE FORMULA will solve the problem.

In a form, you want a drop-down list populated with the basic summary report commands. In the object method for that drop-down list, you write:

 Case of
    :(Form event=On Before)
       ARRAY TEXT(asCommand;4)
       asCommand{1}:=Command name(1) ` Sum
       asCommand{2}:=Command name(2) ` Average
       asCommand{3}:=Command name(4) ` Min
       asCommand{4}:=Command name(3) ` Max
  ` ...
 End case

In the English version of 4D, the drop-down list will read: Sum, Average, Min, and Max. In the French version, the drop-down list will read: Somme, Moyenne, Min, and Max.

The following code allows you to load all valid 4D commands in an array:

 C_LONGINT($Lon_id)
 C_TEXT($Txt_command)
 ARRAY LONGINT($tLon_Command_IDs;0)
 ARRAY TEXT($tTxt_commands;0)
 
 Repeat
    $Lon_id:=$Lon_id+1
    $Txt_command:=Command name($Lon_id)
    If(OK=1) //command number exists
       If(Length($Txt_command)>0) //command is not disabled
          APPEND TO ARRAY($tTxt_commands;$Txt_command)
          APPEND TO ARRAY($tLon_Command_IDs;$Lon_id)
       End if
    End if
 Until(OK=0) //end of existing commands

 
PROPERTIES 

Product: 4D
Theme: Language
Number: 538

The OK variable is changed by the command

 
HISTORY 

Created: 4D v6

 
SEE ALSO 

EXECUTE FORMULA

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)

Inherited from : Command name ( 4D v11 SQL Release 6)