C/AL

C/AL

C/AL (Client Application Language) is the programming language used within the C/SIDE Integrated DevelopmentEnvironment in Microsoft Dynamics NAV (Formerly known as Navision Attain).C/AL is a database specific programming language, and is primarily used for retrieving, inserting and modifying records in a Navision database. C/AL is simple but effective, and resembles the Pascal language it is based on.

Datatypes

Methods

A list of commonly used methods.

Insert : Inserts a new record. Modify : Modifys a record. Delete : Deletes a record. Commit : Persists changes to the database. SetRange : Set a simple filter on a record. SetFilter : Set advanced filter on a record. Reset : Resets filters on a record. ModifyAll : Modifies all records within filter. DeleteAll : Deletes all records within filter. CalcFields : Calculates value of Sum index field (SIFT) Create : Initializes an automation variable. Clear : Clears an automation variable.

Datatypes

A list of commonly used datatypes.

File : Basic file manipulation. OCX : OCX object reference. Automation : COM object reference. InStream : Stream for reading. OutStream : Stream for writing. Variant : Equivalent to BASIC's "Object" datatype. Codeunit : Equivalent to a "Class object" containing public and private methods. Form : Equivalent to a windows form. Record : ORM implementation for Navision Tables. RecordRef : A reference to a record(Navision Table). RecordID : A representation of the primary key fields of a record. Dataport : Specialized units for importing/exporting data through textfiles. Boolean : Datatype "boolean". Option : Equivalent to an "ENUM" structure. Integer : Datatype "16-bit integer". Decimal : Datatype "decimal". BigInteger : Datatype "32-bit integer". Char : Equivalent to datatype "char". Text : Datatype "String". Code : Datatype "String" (Capitalized). Date : Datatype Short date. Time : Datatype Short Time. Datetime : Equivalent to SQL datatype "Datetime" Binary : Equivalent to "Byte Array"

Examples

Hello World

This is the classic Hello World example. Since the C/SIDE Development Environment does not have a console to output text, this example is made using a dialog box as the visual interface.

For i:=0 to 10 do begin Message('hello world'); End;

Filtering and retrieving records

Variables in C/AL are not defined through code, but are defined via the variable declaration menu in the C/AL editor. In this example "Item" is assumed to be a variable of type Record.

Item.reset(); if Item.get('31260210') then do begin message('Item name is: %1',Item."Description"); end;

Item.reset(); item.setfilter(..);

Looping and data manipulation

Looping over a recordset and modifying the individual records is achieved with only a few lines of code.

Item.reset(); Item.setrange("Blocked",true); if Item.find('-') then repeat if Item."Profit" < 10 then Item."Profit %" := 20; Item.modify(true); until Item.next =0; Item.modifyall("Blocked",false);

External links

* [http://www.microsoft.com/dynamics/nav/default.mspx/ Official site ]
* [http://www.mibuso.com/ Microsoft Dynamics Development Community ]

nl:C/AL
ru:C/AL


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”