Chapter 7. Intermediate C/AL

 

"A designer is an emerging synthesis of artist, inventor, mechanic, objective economist and evolutionary strategist."

 
 --R. Buckminster Fuller
 

"Beauty of style and harmony and grace and good rhythm depend on simplicity."

 
 --plato

In the previous chapter, we learned enough C/AL to create a basic, operational set of code. In this chapter, we will learn about more C/AL functions and pick up a few more good habits along the way. If you are getting started as a professional NAV Developer, C/SIDE's built-in C/AL functions represent a significant portion of the knowledge that you will need on a day-to-day basis. If you are a manager or consultant needing to know what NAV can do for your business or your customer, an understanding of these functions will help you too.

Our goal is to competently manage I/O, create moderately complex program logic structures, and understand data filtering and sorting as handled in NAV and C/AL. Since the functions and features in C/AL are designed for business and financial applications, we can do a surprising amount of ERP work in NAV with a relatively small number of language constructs.

Keep in mind that anything discussed in this chapter relates only indirectly to those portions of NAV objects which contain no C/AL (for example, MenuSuites, SQL Server Report Builder (SSRB), and Visual Studio Report Designer (VSRD) report layouts). This chapter's goals are to:

  • Review some C/AL development basics
  • Learn about a variety of useful (and widely used) C/AL functions
  • Better understand filtering
  • Apply some of what we've learned to expand our WDTU applicationSome C/AL development tools

All internal NAV logic development is done in C/AL and all C/AL development is done in C/SIDE. Some user interface design is done by means of the SSRB/VSRD. And it is possible to have integrated .NET objects for a variety of purposes.

C/AL Symbol Menu

As an Integrated Development Environment (IDE), C/SIDE contains a number of tools designed to make our C/AL development effort easier. One of these is the C/AL Symbol Menu. When we are in one of the Object Designers where C/AL code is supported, C/AL Symbol Menu can be accessed via either the menu option View | C/AL Symbol Menu or by pressing F5.

The three-column display has variables and object categories in the left column. If the entry in the left column is an object or a variable of function type, then the center column contains subcategories for the highlighted left-column entry. The right column contains the set of functions that are a part of the highlighted center-column entry. In a few cases (such as BLOB fields), additional information is displayed in the columns further to the right. These columns are accessed through the arrows displayed just below the rightmost display column, as shown in the following screenshot:

C/AL Symbol Menu

The C/AL Symbol Menu is a very useful multi-purpose tool for the developer. We can use it as a quick reference to see what C/AL functions are available to us, see the syntax of those functions, access Help on those functions, and view what other systems would refer to as the Symbol Table. We can also use the C/AL Symbol Menu as a source of variable names or function structures to paste into our code.

Use of the C/AL Symbol Menu for reference purposes is not only very helpful when we are a novice C/AL developer but also after we become experienced developers. It is a guide to the inventory of available code tools with some very handy built-in programming aids.

The C/AL Symbol Menu displays the highlighted function's syntax at the bottom left of the screen. It also provides quick access to Developer and IT Pro Help to further study the highlighted function and its syntax. Pressing F1 may bring up the general Developer and IT Pro Help rather than a specific entry (or it may bring up an entry only somewhat related to the focus location.

The second use of the C/AL Symbol Menu is as a symbol table. The symbol table for our object is visible in the left column of the C/AL Symbol Menu display. The displayed symbol set (that is, variable set) is context sensitive. It will include all system-defined symbols, all our Global symbols, and the Local symbols from the function that had focus at the time we accessed the C/AL Symbol Menu. Though it would be useful, there is no way within the Symbol Menu to see all Local variables in one view. The Local symbols will be at the top of the list, but we have to know the name of the first Global symbol to determine the scope of a particular variable (that is, if an entry appears in the symbol list before the first Global, it is a Local variable, otherwise it's Global).

The third use for the C/AL Symbol Menu is as a code template with a paste function option available. This function will be enabled if we have accessed C/AL Symbol Menu from C/AL Editor. Paste is initiated by pressing either the Apply button or the OK button, or highlighting and double-clicking. In each of these cases, the element with focus will be pasted into our code. Apply will leave the Symbol Menu open and OK will close it (double-clicking on the element has the same effect as clicking on OK).

If the element with focus is a simple variable, then that variable will be pasted into our code. If the element is a function whose syntax appears at the lower left of the screen, the result of the paste action (that is, Apply or OK or double-click) depends on whether Paste Arguments (just below the leftmost column) is checked or not. If the Paste Arguments checkbox is not selected, then only the function itself will be pasted into our code. If the Paste Arguments checkbox is selected (as shown in the preceding screenshot), then the complete syntax string, as shown, will be pasted into our code. This can be a very convenient way to create a template to help us enter the correct parameters with the correct syntactical structure and punctuation more quickly.

When we are in the C/AL Symbol Menu, we can focus on a column, click on a letter, and jump to the next column field in sequence that starts with that letter. This acts as a limited Search substitute, like an assisted browse.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.241