# C/AL

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/C/AL
> Markdown URL: https://mediated.wiki/source/C/AL.md
> Source: https://en.wikipedia.org/wiki/C%2FAL
> Source revision: 1255496036
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Not to be confused with [CAL (programming language)](/source/CAL_(programming_language)).

**C/AL** (**C**lient**/**server **A**pplication **L**anguage) was the programming language used within C/SIDE the **C**lient**/S**erver **I**ntegrated **D**evelopment **E**nvironment in [Microsoft Dynamics NAV](/source/Microsoft_Dynamics_NAV) (formerly known as Navision Attain) and [Microsoft Dynamics 365 Business Central](/source/Microsoft_Dynamics_365_Business_Central) up until (and including) version 14. It has been replaced by [AL](/source/AL_(programming_language)). C/AL is a Database specific programming language, and is primarily used for retrieving, inserting and modifying records in a [Navision](/source/Microsoft_Dynamics_NAV) database. C/AL resembles the [Pascal language](/source/Pascal_(programming_language)) on which it is based. The original C/AL compiler was written by Michael Nielsen.[1]

## Examples

### Hello World

This is the classic [Hello World](/source/Hello_world_program) example. Since the [C/SIDE](/source/C/SIDE) (Client/Server Integrated Development Environment) does not have a console to output text, this example is made using a dialog box as the visual interface.

MESSAGE('hello, world!');

### Filtering and retrieving record

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.

IF Item.GET('31260210') THEN
  MESSAGE(STRSUBSTNO('Item name is: %1',Item.Description));

Item.RESET;
Item.SETRANGE("No.",FromItem,ToItem);
Item.FINDLAST;

### 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.FINDSET THEN
  REPEAT
    IF Item."Profit %" < 20 THEN BEGIN
      Item."Profit %" := 20;
      Item.MODIFY(TRUE);
    END;
  UNTIL Item.NEXT = 0;
Item.MODIFYALL("Blocked",FALSE);

## See also

- [Microsoft Dynamics NAV](/source/Microsoft_Dynamics_NAV)

## References

1. Studebaker, David, "[Programming Microsoft Dynamics NAV 2009](https://books.google.com/books?id=OSbD-pcs88sC)," p. 8 (2009)

## External links

- [Microsoft Dynamics NAV Official Site](http://www.microsoft.com/en-us/dynamics/erp-nav-overview.aspx)

---
Adapted from the Wikipedia article [C/AL](https://en.wikipedia.org/wiki/C%2FAL) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/C%2FAL?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
