EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

The define command

The define command is used to specify macros. You can assign a constant to a macro, which applies to the following types of constants: a number, a string, a binary data or an identifier name, furthermore, you can assign a macro to the value of another macro. Later on, the name of the macro should be specified as $macroname or $macroname$ for it to be replaced with its value. It is possible to redefine a macro in other define. Macros are defined enclosed within curly braces, and each line contains only one macro definition. The macro definition consists of a name followed by the equal sign = and the appropriate constant or an expression. We recommend that you use only uppercase letters in the names of macros.

define 
{
   A = 0xFFFF; B = 3.0
   NAME = "First and Last Name:"
   ID = idname
   BB = $B
}

Attributes

You can specify the export and namedef attributes for define. Use the export attribute if you distribute the module as byte code (a .ge file) and want to make it possible to use these macros in other programs. If define has the namedef attribute, all its macros can be used without specifying the '$' character.

define <export namedef> 
{
   FALSE = 0
   TRUE = 1
}

func uint my( uint param )
{
   if param >20 : return FALSE
   if param <10 : return $FALSE  // $FALSE == FALSE
   return TRUE
}

Specifying name for define

You can specify a name for define. In this case, it is possible to access macros both directly and specifying the define name. It is made in order to avoid conflicts between macros from various modules. In this case, access to a macro looks like this: $definename.macroname.

// file1.g
define myflag< export > 
{
   FLAG1 = 0xFFF0
   FLAG2 = 0xFFF1
}
// file2.g 
define flags 
{
   FLAG1 = 0x0001
   FLAG2 = 0x0002
}

func uint my( uint param )
{
   if param & $myflag.FLAG1 
   { ... }
   if param & $flags.FLAG1
   { ... } 
}

Enumeration

Gentee has no separate command for defining enumerations. You can use the define command for that. If a macro has no value assigned to it, its value becomes one time greater than the value of the previous macro. If there is no previous macro or it is not an integer, the value of the current macro is set to 0. Macros can be separated by spaces in case of enumeration.

define
{
   VAL0 VAL1 VAL2 // VAL2 = 2 
   
   ID1 = 100
   ID2 ID3 ID4
   ID5  // ID5 = 104
}

Expressions

Not only numbers, but also expression results can be assigned to macros. Either constants or other macros can be operands in expressions. You can take a look at the full list of possible operations on the Macro expressions page.

define
{
   VAL0 = 10 + 245
   VAL1 = $VAL0 + ( 12 - 233 ) 
   VAL2 = $VAL1 & 0xFFFF
   SUMMARY = $VAL0 | $VAL1 | $VAL2
}

Related links