Nav Manual
Nav Manual
Nav Manual
com/translate_f
1. Programming Language C / LA for Microsoft Business Solutions Navision Pablo Espada Well www.esbupa.com 2.
www.programadorautonomo.net Note: Microsoft, Navision, C / AL, etc ... are trademarks of Microsoft I usually devote to training and development work and consulting. NET Also impart training on Navision Development If you want to work with you giving them training or developing a project, please contact: Web www.programadorautonomo.net www.esbupa.com Email [Email_address] [Email_address] Hope you like the presentation Contact
3. Language C / AL - Index
Data Types Variables Features Operators Judgments Allocation Decision (IF, CASE) Iteration (FOR, REPEAT, WHILE) Other Comments Tables Object Access Forms Information Source Units Dataports Common Functions SumIndexFields Flowfields Dialogues File Access Scrubber Tracking Code Code Wizard OCX BLOB Standard Format
4. Introduction
1 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
4GL language environment to work in Navision Specialized work on relational DB Integrated in Windows environment OCX to access data from other applications File Access
5. Data Types
Key variables: Numeric Integer Numbers between 2147483647 and +2,147,483,647. BigInteger 64-bit number. L is used to indicate that is a long integer: bi: = 3983200032984209L. Decimal Numbers and +10 E63-10E63. 18 significant digits. Char A character between 0 and 255, freely convertible to whole character. Operable as an integer or a character: C: = 'A'; C: = S [2]; C: = C + 1; Option Option number between 2147483647 and +2,147,483,647, freely convertible at the option entirely. The options are the property symbolically declare the variable OptionString: OptionString = Offer, Order, Invoice, Payment
2 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
0T is initialized with Time: = 123000T; DateTime Stores a UTC time. Always adapted to local time display 0T is initialized with DateTime: = December 31, 2004, 14:20:59.999.;
9. Complex Types
C / AL includes a set of complex types used in certain cases BLOB Used to store binary (images, files, videos, etc. ..) and is stored outside the record of the database. 2GB Max Size Record A record is associated with a record of each table. Access to fields is done by writing the name of the record, a point and the field name: EJ: Customer. "No."
3 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
Unique Identifier of the system. 16 bytes: 12345678-1234-1234-1234-1234567890AB TableFilter Lets you apply a filter to a table. Only used for Permits
13. Variables
Initialization C / AL variables initialized to default values: Boolean: FALSE Numeric: 0 Strings:'' Date: 0D Time: 0T
4 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
Option can create a variable and display their values as follows: MESSAGE ('The value of% 1 is% 2', 'LoopNo' LoopNo)
18. Features
Definition The function is defined with a name, a number of optional parameters and optional return value. They can have local variables. The parameters can be by reference (amending its value, eg "value") or by value (the value is not altered, eg: "flag") Can be called from other objects Operators Operator C / AL Meaning . camp registration form or report control () Parentheses [] Indexing :: Scope + Sum - Subtract * Multiply
19.
5 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
20.
/ Division DIV integer division MOD rest > Greater than > = Greater than or equal to <Less than <= Less than or equal = Equal to <> Different IN membership of a range (set) AND Logical AND OR Logical OR NOT logical negation Logical XOR exclusive OR .. Rank Operators (II) 1. . field in a record [] Indexing () Parentheses :: Scope 2. NOT logical negation - Investment of sign or negative sign + Positive sign 3. * Multiply / Decimal division DIV integer division MOD rest AND Logical AND Logical XOR exclusive OR
4. + Add - subtract logical OR O 5. > Greater than <less than> = greater than or equal to <= less than or equal to = equal to <> IN other than belonging to all 6. .. Precedence range
6 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
24.
[] Indicates optionality in that part of the sentence. A statement block contains a set of statements between BEGIN and END; Begin <sentencia> <sentencia> .. End; A <expression> returns a value. A <expr-asignacin> assigns the value expression result to a variable. The field name, if it contains spaces or special characters, is written in "quotes" Sentences (I) Allocation Assignment Operator today: = 220704D; value: = 4; As a result of function call Return value of a function Function square (value: Integer) Quad: Integer Begin sq: = value * value End; value: = Square (3), / / value is equal to 9 Passing parameters by reference to a function Cube Function (VAR value: Integer) Begin value: = value * value * value End; value: = 2; Cube (value) / / value is equal to 8
7 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
27.
Example IF (Quantity = 0) AND ("Invoiced Amount" <> 0) THEN Testfield (Order No. mov. Asoc product. ") ELSE BEGIN IF Quantity <> "Invoiced Amount" THEN Testfield ("Invoiced Amount", 0); Testfield (Order No. mov. Asoc product. ", 0); END; Examples Modify the above form as follows:
28. Examples
Add what is necessary to calculate the average units sold / bought Accountants of times you buy / sell Total Sales / Shopping
29. Examples
On the example above, add the TextBox a list of 10 and 10 decimal Array We must make every time you click the Run button, the result is displayed in a different position from Array Sentences (III) Decision CASE Evaluates the expression and executes the statement block of corresponding value. If there is an equal value, execute the judgments of the ELSE block. CASE OF <expression> <value>: <bloque of sentencias>; ... <value>: <bloque of sentencias> [ELSE <bloque of sentencias>] END; Example CASE "Type amount" OF Type "value":: Balance: ValorCol: = CGCta. "Pptdo amount." Type "amount":: Please: BEGIN ValorCol: = CGCta. "Should be budgeted" Do: = TRUE; END ValorCol ELSE: = CGCta. "To have budgeted" END;
30.
8 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
Repeats a set of statements until the result of the assignment expression reaches the value indicated <expr-asignacin> FOR TO / DO DOWNTO <value> <Block of statements> Example FOR j: = Tasks DOWNTO 1 DO BEGIN Inclination [j]: = Inclination [j - 1]; Constant [j]: = Constant [j - 1]; MaxValImport [j]: = MaxValImport [j - 1]; END;
9 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
WITH The statements inside the WITH refer to the registration form, etc. Clie DO BEGIN WITH "No.": = '1 '; Name: = 'Pepe'; Address: = 'Rue the Barnacle, n 13'; City: = "Niu wept '; END; EXIT Leave a segment of code or function (you can return the value) Absolute FUNCTION (value: Integer) ret: Integer BEGIN IF (value <0) THEN BEGIN ret: =-value; EXIT; END; EXIT (value); END;
35. Comments
/ / - A single line / / Find next register no. ('+') ItemReg.FIND IF THEN ItemRegNo: = ItemReg. "No." + 1 ELSE ItemRegNo: = 1; () - Several lines (Find next register no. ) ('+') ItemReg.FIND IF THEN ItemRegNo: = ItemReg. "No." + 1 ELSE ItemRegNo: = 1;
36. Examples
Modify the form to always show the 10 most recent results, always showing in the first position (upper) the final result
37. Examples
Added to form an "Order" and will make an arrangement of the elements through the bubble method
38. Examples management repeat until the array is ordered 39. Examples are improving the algorithm at each iteration, knowing that the last element is always "orderly" 40. Tables
Where enter code
10 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
Triggers table: OnInsert. It runs when you insert a record into the table. OnModify. It runs the modiicar a field in a table row. OnDelete. It runs to delete a table row. OnRename. It runs when editing a field that is part of the primary key of a table row. Releases of fields in the table: OnValidate. It runs to change the value of a field. OnLookup. It runs when you press F6 on the field to find a value. Functions defined in a table You can define functions in the table and call them from the object itself or from other objects.
11 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
12 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
IF ListaClientes.RUNMODAL = ACTION:: LookupOK THEN BEGIN ListaClientes.GETRECORD (Clie) cliente.validate (Clie. "No."); CLEAR (ListaClientes) END; Suitable filters are set in the variable type Clie Client Record. ListaClientes is of type Form. SETTABLEVIEW set the form view and set the client ListaClientes asset by SETRECORD. LOOKUPMODE serve causes the form to retrieve data. GetRecord get the record marked. CLEAR removes the form.
13 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
51. Forms
Where enter code Form Releases: OnAfterGetRecord. It runs the recurperar a record of the table, but before displaying the registration form. Triggers form controls. Buttons on the form: Command Button Menu Button: In each of the Menu Items Functions defined in a form: You can define functions in the form and call them from the object itself or from other objects. In any case, the code must be written in the table if possible!
54. Information
Where enter code Releases of the report: OnPreReport. Is processed before running the report. Releases of each DataItem: OnPreDataItem. It runs before the DataItem is processed. OnAfterGetRecord. It runs every time you get a record. OnPostDataItem. Is executed after the processing of DataItem. Report Request Form. Functions defined in a report. Sections of the form:
14 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
OnPreSection. It runs before a section is processed. OnPostSection. It runs after a section is processed.
59. Dataports
Where enter code DataPort Triggers OnPreDataport. Before the implementation of the Dataport. OnPostDataport. After the execution of the Dataport. DataItem Triggers OnPreDataItem (). Before processing the DataItem. OnBeforeExportRecord (). Before you export a record. OnAfterExportRecord (). After you export a record. OnBeforeImportRecord (). Before importing a record. OnAfterImportRecord (). After importing a record.
15 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
OnPostDataItem (). After processing a DataItem. The Dataport Request form Features Dataport
16 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
17 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
69. SumIndexFields
[Ok: =] Record. CALCSUMS (Field1, [Field2] ,...) Returns the sum for one (or more) SumIndexField. Must be on a key that has defined the field. There should be filters in fields outside the key. If the above conditions are met, it returns FALSE (or throws an error message). MovCli.SETCURRENTKEY ("Customer No.", "record date"); MovCli.SETRANGE ("Customer No.", "AAA 1050"); MovCli.SETRANGE ("Registration Date", 010199D, 123102D) MovCli.CALCSUMS (Import) FlowFields [Ok: =] Record. CALCFIELDS (Field1, [Field2] ,...) The table fields are FlowFields must be recalculated by applying filters. Cliente.SETRANGE ("Filter dates, 010199D, 123102D) Cliente.CALCFIELDS (Balance, "Balance Period"); Dialogues Posts: Asynchronous Message MESSAGE MESSAGE ('Message asynchronous information'); ERROR. Causes Rollback. ERROR ("ERROR: This runs RollBack '); . FIELDERROR. Displays the Wrong Field Message + Ok / Cancel CONFIRM IF CONFIRM ('want to continue') THEN Code> to SI> ELSE Code> to NO>
70.
71.
18 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
'New Name # 3 ############### \' + '@ 4@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); Num: = 0; Ventana.UPDATE (1, 'Client Table'); Clie.RESET; ('-') THEN IF Clie.FIND REPEAT Num: = Num + 1; Ventana.UPDATE (2 Clie.Nombre) Ventana.INPUT (3, newName); Ventana.UPDATE (4, ROUND ((Num / Clie.COUNT) * 10000)); Clie.VALIDATE ("Name", newName); UNTIL Clie.NEXT = 0; Ventana.CLOSE;
19 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
Str: = USERID; COMPANYNAME. Returns the current company Str: = COMPANYNAME; OSVersion. Returns a string indicating the current operating system Str: = OSVersion; WORKDATE. Returns the current working date TFecha: = WORKDATE; TODAY. Returns the date of the operating system Date: = TODAY; TIME. Returns the operating system time Time: = TIME;
20 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
21 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
83. Examples
Modify the code above (Execute button) to split it into functions / procedures
84. Scrubber
It is active in: Tools / Debugger / Active Breakpoint on Triggers execution stops at each trigger or function. You can set breakpoints to stop execution (F9) Code Variables Pile Other expressions Output messages Tracking Code It is active in: Tools / Debugger / Code Coverage
85.
Tracking code executed between Start and Stop Case In Black performed in non-executed Red
87. BLOB
Data Type Microsoft Business Solutions Navision Able to hold large amount of information (eg photos) Define a variable of type BLOB and Subtype Bitmap
22 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
23 of 24
03-08-10 4:38 PM
http://translate.googleusercontent.com/translate_f
de fin. BIEN IF x < y THEN BEGIN REPEAT x := x + 1; UNTIL x = y; b := x; END; WHILE y DO van en la misma lnea. BIEN WHILE z < a DO BEGIN a := a + 1; b := b - 1; END;
24 of 24
03-08-10 4:38 PM