Share via


X++ Keywords

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

The X++ keywords shown in the following table are reserved. These keywords cannot be used for any other purpose.

Reserved word

Description

More information

!

Not.

Relational Operators

!=

Inequality operator (not equal to).

Relational Operators

#

Prefix on macro names.

How to: Use #define and #if to Test a Macro

&

Binary AND.

Arithmetic Operators

&&

Logical AND.

Relational Operators

(

Function call operator, which indicates the beginning of the function call.

)

Function call operator, which indicates the end of the function call.

*

Multiply.

The asterisk (*) is also used in X++ SQL. One use is to signify all fields from the tables on a select statement. Another use is as a wildcard with the like operator, to signify 0 to many characters of any kind. The like operator also uses the ? character.

Arithmetic Operators

^

Binary XOR.

Arithmetic Operators

|

Binary OR.

Arithmetic Operators

||

Logical OR.

Relational Operators

~

Not.

Arithmetic Operators

+

Plus.

Arithmetic Operators

++

Increment.

Assignment Operators

+=

Additive assignment.

Assignment Operators

,

Comma operator. Expressions separated by commas are evaluated left-to-right.

-

Minus.

Arithmetic Operators

--

Decrement operator.

Assignment Operators

-=

Subtractive assignment.

Assignment Operators

.

Class member access operator, for example, formRun.run accesses the run method of an object of the class type FormRun.

/

Divide.

Arithmetic Operators

\

Escape in strings. Escapes extra quotation marks, and certain letters such as \t for tab.

@

Escape of keywords. For example, str @abstract; would fail to compile without the @ sign.

Also affects literal strings, by negating the effect of the \ escape character, and by enabling the string to span more than one line in the source code. The new line is represented by one character of hexadecimal 0x0A, which is commonly called a line feed. No carriage return character of hexadecimal 0x0D is included, as in 0x0D0A.

:

Field declaration or label specifier.

The colon (:) character is also used on the switch statement.

::

Used to call static (class) methods: ClassName::methodName.

;

Terminates statements. Used in for loops or as a separator of statements.

<

Less than.

Relational Operators

<<

Left shift.

Arithmetic Operators

<=

Less than or equal.

Arithmetic Operators

=

Assignment operator. The argument to the left of "=" is set to the value of the argument to the right.

Assignment Operators

==

Returns true if both expressions are equal.

Relational Operators

>

Greater than.

Relational Operators

>=

Greater than or equal.

Relational Operators

>>

Right shift.

Arithmetic Operators

?

Ternary operator.

The question mark (?) character is also used by the like operator to signify exactly one character of any kind. The like operator also uses the * character.

Ternary Operator (?)

[

Array declarator, open. Must be used with "]".

]

Array declarator, close. Must be used with "[".

{

Indicates the beginning of a number of statements. The last of these statements must be followed by a "}".

}

Indicates the end of a number of statements. A "{" must appear before the first of these statements.

abstract

Class and method modifier. An abstract class cannot be constructed with the new keyword. An abstract method cannot be called.

A table can also be modified as abstract by setting its Abstract property to Yes in the AOT, or by using the DictTable class. The Abstract property defaults to No, and it cannot be set unless the table is extended by another table. Each row in an abstract table must have a dependent row in a derived table. This means that each row in an abstract table has a value greater than 0 (zero) in its InstanceRelationType property field. There are no other effects from marking a table as abstract.

Informally, programmers often use the term concrete to describe a class that is non-abstract.

Method Modifiers

Table Inheritance Overview

anytype

The method can return any data type.

Anytype

as

Needed when you assign a base class variable to a derived class variable. For example, given a Derived class that extends a Base class, the statement myDerived = myBase as Derived; avoids a compiler error by using the as keyword. This keyword also applies when you assign a base table variable to a derived table variable.

Expression Operators: Is and As for Inheritance

asc

An option on the order by or group by clause in a select statement. The sorting is ascending.

Select Statement Syntax

at

Specifies the position of a print window.

Print Statements

avg

Returns the average of the fields from the rows specified by the group by clause in a select statement.

Select Statement Syntax

break

Immediate exit from code block.

Break Statements

breakpoint

Represents a breakpoint that is set for debugging purposes. To set a breakpoint in your code, write:

breakpoint;

by

Part of a reserved term, such as group by and order by.

byref

Specifies that the parameter being passed to the called method is being passed by reference (address), instead of by value. Byref is used in X++ when calling a .NET method that takes a parameter by reference (such as with the C# keywords out or ref).

How to: Use the byref Keyword for CLR Interop.

case

Selection within a switch statement.

Switch Statements

catch

Used in exception handling.

Exception Handling with try and catch Keywords

changeCompany

Changes database settings to another company.

Change Company Design Pattern

class

Declares a class.

Classes in X++

client

Method modifier.

Method Modifiers

container

Specifies a variable of type container.

Containers

continue

Forces the next iteration of a loop.

Continue Statements

count

Returns the number of records from the rows specified by the group by clause in a select statement.

Select Statement Syntax

crossCompany

Causes a select statement to return data for all companies that the user is authorized to read from.

Cross-Company X++ Code Basics

date

Specifies a variable of type date.

Dates

default

Default case within switch statements.

Switch Statements

delegate

A class member that is able to store multiple references to methods in other classes, and to call all those methods when prompted to do so. A delegate can store references to various kinds of methods including the following:

  • static methods on X++ classes

  • instance methods on X++ classes

  • methods on .NET Framework classes

Event Terminology and Keywords

X++, C# Comparison: Event

delete_from

Allows you to delete multiple records from the database at the same time.

delete_from

desc

An option on the order by or group by clause in a select statement. The sorting is descending.

Select Statement Syntax

display

Method modifier.

Method Modifiers

div

Integer division.

Arithmetic Operators

do

Beginning of a do...while loop.

Do...while Loops

edit

Method modifier.

Method Modifiers

else

Conditional execution (if...else).

if and if ... else Statements

eventHandler

Must be used each time you either add or delete a method reference from a delegate by using the += or -= operator. For example:

myDelegate += eventHandler(OtherClass::myStaticMethod);

Event Terminology and Keywords

X++, C# Comparison: Event

exists

Used with join clauses in select statements.

Select Statement Syntax

extends

A class or interface declaration clause. If your class does not explicitly extend another class, your class is considered to extend the Object class (as if you had written "extends Object").

Creating a Subclass

false

Boolean literal.

Booleans

final

Class and method modifier.

Method Modifiers

firstFast

Used in select statements to speed up the fetch for the first row.

Select Statement Syntax

firstOnly

Used in select statements to fetch only the first record.

The firstOnly keyword does not guarantee that a maximum of one record is retrieved by an X++ SQL select statement. If the AOS can use the EntireTable cache to satisfy the data demands of the select statement, the firstOnly keyword is ignored.

Select Statement Syntax

Set-based Caching

firstOnly10

Same as firstOnly, except returns 10 rows instead of one.

firstOnly100

Same as firstOnly, except returns 100 rows instead of one.

firstOnly1000

Same as firstOnly, except returns 1000 rows instead of one.

flush

Clears an entire table cache. Here is the syntax for the flush statement:


 YourTable ytBuffer; 
 flush ytBuffer;

Set-based Caching

for

For loop iteration.

For Loops

forceLiterals

Used in select statements to reveal actual values that are used in where clauses to the Microsoft SQL Server database at the time of optimization.

Select Statement Syntax

forceNestedLoop

Forces the SQL Server database to use a nested-loop algorithm to process a particular SQL statement containing a join.

Select Statement Syntax

forcePlaceholders

Used in select statements to instruct the kernel not to reveal the actual values used in where clauses to the Microsoft SQL Server database at the time of optimization.

Select Statement Syntax

forceSelectOrder

Forces the SQL Server database to access the tables in a join in the specified order.

Select Statement Syntax

forUpdate

Selects records exclusively for update. The operation to be performed on the records that are fetched is an update. Depending on the underlying database, the records may be locked for other users.

Select Statement Syntax

from

Part of a select statement. The from clause specifies the table in which the columns exists.

Select Statement Syntax

group

Part of the group by clause in a select statement.

Select Statement Syntax

if

Conditional execution.

if and if ... else Statements

implements

Implements an interface.

Interfaces Overview

insert_recordset

Copies data from one or more tables into one resulting destination table on a single server trip.

insert_recordset

int

Specifies a variable of type integer (32-bit).

Integers

int64

Specifies a variable of type integer (64-bit).

Integers

interface

Interface declaration.

Interfaces Overview

is

Asks whether the object referenced by a class variable either inherits from the given class or is of the given class. For example, given a Derived class that extends a Base class, the expression (myDerived is Base) returns true. This keyword applies to class inheritance and table inheritance.

Expression Operators: Is and As for Inheritance

join

Tables are joined on columns common to both tables. You can generate a single result set based on multiple tables through the use of joins.

Select Statement Syntax

like

Tests for matches by pattern, with wildcard symbols * and ?.

The string on the right side of the like operator must use four backslash characters to represent one backslash. Examples follow:

  • ("\\" like "*\\*" ) //Resolves to false.

  • ("\\" like "*\\\\*") //Resolves to true.

Relational Operators

maxof

Returns the maximum of the fields from the rows specified by the group by clause.

Select Statement Syntax

minof

Returns the minimum of the fields from the rows specified by the group by clause.

Select Statement Syntax

mod

Returns the integer remainder of the left expression1 divided by the right expression2. Informally this is sometimes called the modulo operator.

((12 mod 7) == 5) is true.

new

Operator. Creates an instance of an anonymous class that is assignment-compatible with the named class/interface reference variables, or allocates memory for an array.

next

Fetches the next record in a table.

noFetch

Indicates that no records are to be fetched at present.

Select Statement Syntax

notExists

Used with join clauses in select statements.

Select Statement Syntax

null

Symbolic constant.

optimisticLock

Forces a statement to run with optimistic concurrency control, even if a different value is set on the table.

Select Statement Syntax

order

Part of the order by clause in a select statement.

Select Statement Syntax

outer

outer join.

Select Statement Syntax

pause

Halts the execution of a job. The user is asked to state whether execution should continue.

Select Statements

pessimisticLock

Forces a statement to run with pessimistic concurrency control, even if a different value is set on the table.

Select Statement Syntax

print

Allows you to display output on the screen.

Print Statements

private

Method access modifier.

Method Access Control

protected

Method access modifier.

Method Access Control

public

Method access modifier.

Method Access Control

real

Specifies a variable of type real.

Reals

repeatableRead

Specifies that no other transactions can modify data that has been read by logic inside the current transaction, until after the current transaction completes.

An explicit transaction completes at either ttsAbort or at the outermost ttsCommit.

For a stand-alone select statement, the transaction duration is the duration of the select command. However, the database sometimes enforces the equivalent of repeatableRead in individual select statements even without this keyword appearing in your X++ code (depending on how the database decides to scan the tables).

For more information, see the documentation for the underlying relational database product.

retry

Used in exception handling.

Exception Handling with try and catch Keywords

return

Exits from a method.

Declaration of Methods

reverse

Records are returned in reverse order.

Select Statement Syntax

select

The select clause designates which columns or views are shown in the result set.

Select Statements

server

Method modifier.

Method Modifiers

setting

Used with the update_recordset command.

update_recordset

static

Static methods may not refer to instance variables (only to static variables); may be invoked by using the class name rather than on an instance of the class ("MyClass.aStaticProcedure").

Method Modifiers

str

Specifies a variable of type string.

Strings

sum

Returns the sum of the fields from the rows specified by the group by clause in a select statement.

Select Statement Syntax

super

Calls the method that was overridden by the current method.

Table Methods

switch

Switch selection statement.

Switch Statements

tableLock

Obsolete; tableLock is no longer available.

this

A reference to the current instance of the class.
Used in X++ code inside a method of the class.
Used to reference method members of the class, but not field members of the class.


 public str getFullName() 
 { 
     // Next statement fails to compile without 'this.'. 
     return this.concatenateFirstAndLastNames(); 
 }

Loosely similar to the system variable that is named element. You use element in form control methods to reference the containing form. For more information, see Using Variables with Forms.

throw

Used in exception handling.

Exception Handling with try and catch Keywords

true

Boolean literal.

Booleans

try

Used in exception handling.

Exception Handling with try and catch Keywords

ttsAbort

Discards all changes in the current transaction.

Transaction Integrity

ttsBegin

Marks the beginning of a transaction.

Transaction Integrity

ttsCommit

Marks the end of a transaction.

Transaction Integrity

update_recordset

Allows the manipulation of row sets within one operation.

update_recordset

validTimeState

Filters rows that are retrieved from a valid time state table by an X++ SQL select statement. For example:
 select validTimeState(myDateEffective) * from xMyTable; 
...or...
 select validTimeState(myDateFrom, myDateTo) * from xMyTable;

Effects of Valid Time State Tables on Read and Write Operations

void

Identifies a method that does not return a value.

Declaration of Methods

where

Part of a select statement. The where clause specifies the conditions to be satisfied; that is, the rows that you want to include in the result.

Select Statement Syntax

while

Iteration statement. Executes a statement or block repeatedly when a test condition is true.

While Loops

while select Statements

window

Allows you to alter the size of the output window.

Print Statements

See also

X++ Grammar

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.