NAV2013 Beta to RTM - Some Striking Code Changes #4: Redundant Record References

Published 2012-10-18 14:00

In C/AL we address fields and methods of record variables using the syntax <Record>.<Field> and <Record>.<Method>. To make coding somewhat simpler and the resulting code leaner, with the goal of being easier to read, C/SIDE - uhh NAV DE now we're on NAV 2013 - has a couple of ways to make implicit references to the record variable.

  1. using the WITH statement; as the C/SIDE Reference Guide puts it:

    If you work continuously with the same record, you can use WITH statements. When you use a WITH statement, you only have to specify the record name once.

  2. using the Rec variable on any table, bounded page (and form) or codeunit OnRun trigger having the TableNo property set
  3. using the DataItem variable of the associated DataItem on any report (or dataport)
  4. using a field as parameter in a record method call, examples being:

    <Record>.SETFILTER(<Field>,...)
    <Record>.
    SETRANGE(<Field>,...)
    <Record>.
    SETCURRENTKEY(<Field>,...)

As part of the code cleanup between NAV 2013 Beta and RTM, explicit references to record variables, where they could be implicit, have been removed.

The accompanying screen shots show examples of case 1 and 4.

Click on the images to get a full view that's readable.

Filed under: ,

Comments

# Van Vugt's dynamiXs said on Friday, October 26, 2012 12:42 PM

In my previous post in this series I addressed the first sync with coding standards, i.e. removal of

# Van Vugt's dynamiXs said on Sunday, November 04, 2012 6:10 PM

You might recall that for NAV 2013 Beta I noted down the objects statistics here . So here is a small

Leave a Comment

(required) 
(required) 
(optional)
(required)