Nav Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

http://translate.googleusercontent.

com/translate_f

Programming with C / AL for Microsoft Business Solutions Navision - Presentation Transcript

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

6. Data Types (II)


Key variables: String Text Chains of up to 250 characters. Their characters are indexed: Name [3] Code Strings of up to 250 characters. Capitalized. The system automatically does the conversion, and removes leading and trailing spaces. His characters are indexed: CodFormasPago [3]

7. Data Types (III)


Key variables: Date and Time Date Stores a date. 0D is initialized. today: = 220704D; Time Store an hour

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.;

8. Data Types (and IV)


Key variables: Boolean Boolean Logical values: TRUE or FALSE

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."

10. Complex Types (II)


Form It represents a form. Each form is composed of a set of controls Report Represents a Report Codeunit Container code, organized in functions File File Type. It gives access to a file system file

11. Complex Types (III)


Dialog Represents a dialog box. DateFormula Represents a formula for the function CALCDATE GUID

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

12. Complex Types (IV)


RecordRef Pointer to a registry. It differs from the type Record that, a priori, know the table that will write. The fields are equivalent FieldRef The key is the equivalent keyref RecordID Stores the ID of the table with Primary Key. InStream and OutStream Can read and write BLOB's Variant Undefined type required for the use of OCX Contains: record, file, action, codeunit, Automation, boolean, option, integer, decimal, char, text, code, date, time, binary, DateFormula, TransactionType, InStream and OutStream. BigText Similar to the BLOB but only for text content. MAX 2GB

13. Variables
Initialization C / AL variables initialized to default values: Boolean: FALSE Numeric: 0 Strings:'' Date: 0D Time: 0T

14. Variables (II)


Definition Variables in C / AL can be: Local: Its scope is the function which defines Global: Its scope is the object which defines

15. Variables (III)


Example: We will create a new CodeUnit Define a set of variables (local and global)

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)

16. Variables (IV)


Arrays and matrices Property is defined Dimensions variable Dimensions = 4, 3 Brackets is the reference SaldoCtaBanco [2,2] indices have range 1 ... n Features: CLEAR (Clear all Array) Arrayl (Returns the length of the array)

17. System Variables


System variables (system-defined variables) C / SIDE creates and makes available to the programmer in certain contexts Rec When you edit a record, Rec contains the record in its modified state. xRec When you edit a record, xRec contains the record before the amendment. CurrForm Variable that represents the current Form object. CurrReport Variable that represents the current Report. RequestOptionsForm Variable that represents the input dialog form object Current Report. CurrFieldNo The field number of the current field from what was called the trigger.

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

21. Operators (III) 22. Examples


We created a new standard form sheet We add three TextBox and a Button (Run) We associate the three TextBox with 3 variables: Value1: Integer Value2: Integer Result: Boolean When you press Run, make the following comparisons: Result: = Value1> Value2; Result: = (Value1> = Value2) AND (Value1 <= Value2 * 2)

23. Judgments - Rules


Notation and rules A sentence begins, as the previous separator. The ELSE part of IF statements is part of the same sentence.

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

25. Chain Operator


The symbol '+' is used to concatenate strings What happens if we make an allocation of a string with the concatenation of two others, and this result is larger than the chain? There is a runtime error We can solve the overflow by checking first: MAXSTRLEN you return the maximum string size COPYSTR lets you copy n characters from a string to another. Use F5 (Symbol menu) to help

26. Sentences (II)


Decision IF Evaluate the condition, if true execution of the IF statement block, otherwise the ELSE Part. <condition> IF THEN <bloque of sentencias> [ELSE <bloque of sentencias>]

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:

Variables Definition Execute Execute OnPush Clear

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.

31. Sentences (IV)


Iteration FOR

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;

32. Sentences (V)


Iteration REPEAT .. UNTIL Repeats a set of statements until the expression evaluates to TRUE. REPEAT <bloque of sentencias> UNTIL <expression> Example ('-') THEN IF CGCta.FIND REPEAT Result: = Result + CalcCGCta (CGCta, ColumEsqCta) Num: = Num + 1; UNTIL CGCta.NEXT = 0;

33. Sentences (VI)


Iteration WHILE .. DO Repeat the set of statements until the next END if the expression evaluates to TRUE DO WHILE <expression> <bloque of sentencias> [END;] Example LinComentVenta.SETRANGE ("Document Type", "document type"); LinComentVenta.SETRANGE ("No." "No."); ('-') DO BEGIN WHILE LinComentVenta.FIND LinComentVenta.DELETE; LinComentVenta. "Document Type": = CabVta. "Document Type"; LinComentVenta. "No.": = CabVta. "No." LinComentVenta.INSERT; END;

34. Sentences (and VII)


Other

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.

41. Tables (II)


To access the variables defined tables Record type Modifying fields in the table: By assigning values. Clie: Record (Client) / / Variable type Clie record / / customer table Clie. "No.": = '10 '; Clie. "Name": = 'Pepe'; With the ruling Validate, assigns the value and executes the trigger OnValidate each field assigned to the Customer table. Clie: Record (Client); Clie.VALIDATE ("No.", '10 '); Clie.VALIDATE (Name, 'Pepe');

42. Tables (III)


Working with records from the table: Initialization. Is set each field in the record to its default value depending on its type. Clie: Record (Client); Clie.INIT; Insertion of records in the table. With the INSERT statement and a parameter that indicates whether the trigger executes OnInsert of the table or not. Clie.VALIDATE ("No.", '10 '); Clie.VALIDATE (Name, 'Pepe'); ... Clie.INSERT (TRUE); Amendment of records in the table. Judgement MODIFY with a parameter that indicates whether the trigger executes OnModify of the table. Clie.VALIDATE (Name, 'Luis'); Clie.MODIFY (TRUE);

43. Tables (IV)


Working with records from the table: Deleting records in the table. By DELETE statement and a parameter that indicates whether the trigger executes OnDelete of the table or not. Clie.DELETE (TRUE); Changing fields of records in the table as part of the primary key. Judgement RENAME with a parameter that indicates whether the trigger executes OnRename of the table. Clie.VALIDATE ("No.", '21 '); Clie.RENAME (TRUE);

11 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

44. Tables (V)


Finding records in a table: Get a record from a table by its primary key. Job.GET (N ."); Job Job.TESTFIELD (Blocked, FALSE); In previous statements we obtain a Job table row (Case GET) and found that one of the fields in the record has the value indicated (testfield) Get one or more record in a table for secondary keys. Clie.RESET; Clie.SETCURRENTKEY (Name, Address, City); Clie.SETRANGE (Name, 'Luis'); Clie.SETFILTER (City, '% 1 |% 2', 'Paris', 'Rome'); First act on the Clie variable filters and removing all previous ranges (RESET). Activate a key by which we will seek (SETCURRENTKEY) for setting search ranges and registration is based on the key indices to be more effective. Filters are set with two functions: SetFilter SetRange and basically the same but SetFilter allows for more complex conditions. It is advisable to set filters on fields in the order they appear on the primary key. Clie currently contains all records that meet the conditions of the filters.

45. Tables (VI) 46.


Finding records in a table: Traverse table records ('-') THEN IF Clie.FIND REPEAT registro> <tratar UNTIL Clie.NEXT = 0; FIND allows for a record within the filter set. The parameter follows: '-' Making the first record of the filter '+' Making the last record filter '=' Takes the record that is equal to the key values (default) FIND returns a Boolean value and if not find a record that complies with the requirements of the filter causes a runtime error. To avoid this error can be enclosed in an IF statement. NEXT next record takes the basket and takes one parameter: > 0 finds the next record skipping the indicated number <0 finds the record skipping the number listed above By default searches for the next record.

47. Tables (and VII)


OnLookup: Search field values in another table. Clie.SETCURRENTKEY ("No."); Clie.SETFILTER ("N ",'< 40 000 '); ListaClientes.SETTABLEVIEW (Clie) Clie.FIND ('-') THEN IF; ListaClientes.SETRECORD (Clie) ListaClientes.LOOKUPMODE (TRUE);

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.

48. Object Access


Form: Shortcut: ('-'); CGMov.FIND FORM.RUN (FORM:: "Movs. Accounting," CGMov) IF FORM.RUNMODAL (216 LinPptoProy) = ACTION:: LookupOK THEN BEGIN "Cod. Phase": = LinPptoProy. "Cod. phase "; "Cod. Subphase": = LinPptoProy. "Cod. subphase " "Cod. Task": = LinPptoProy. "Cod. task "; END; Variable access: ListCtaCG: Form "Accounts List" ListCtaCG.LOOKUPMODE (TRUE); IF ListCtaCG. RUNMODAL = ACTION:: LookupOK THEN ... FormNavegar: Form "Browse" FormNavegar.DefDoc ("Registration Date", "No."); FormNavegar. RUN;

49. Access Objects (II)


Report: Shortcut: Clie.SETRECFILTER / / put a filter (in the primary key) / / for the Report to run only on the / / Current Customer REPORT. RUN (REPORT:: "Inf-example" ReqForm, FALSE, Clie) REPORT. RUNMODAL (REPORT:: "Inf-example", FALSE, Printer, Clie) Variable access: r: Report Supplier - Lines orders "; Clear (r); Prov.SETRECFILTER; r.SETTABLEVIEW (Prov) r. RUNMODAL; ... r. RUN;

13 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

50. Access to Objects (and III)


Codeunit: It performs the function of the Codeunit RUN Shortcut: IF CODEUNIT. RUN (22, LinDiaProd) THEN ... Variable access: DiaGenTestLin: Codeunit "Dia. Test Gen-line "; DiaGenTestLin. RUN (LinDiaGen) / / LinDiaGen may have changed (VAR)

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!

52. Forms (II)


After retrieving a record from the table, but before it is displayed in the form OnAfterGetRecord trigger execution. Ex: Before showing the registration, apply a filter and calculates the value of a SumIndexField showing on the form.

53. Forms (and III)


Clicking on a button or a menu option in a dropdown button runs the trigger OnPush. Example: We can invoke a function in a one-parameter Codeunit.

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.

55. Reports (II),


Before the execution of a trigger Report OnPreReport runs. Example: We can use the filters for which the Report has been called, and then print them in a section Header (FiltClient and FiltMovProducto).

56. Reporting (III)


Before the implementation of a DataItem OnPreDataItem fires. Example: We can use it to maintain a field total for a section with the function CREATETOTALS FOOTER. You can also set a record for page NEWPAGEPERRECORD function, if we chose the option in the Request Form. After obtaining a record of running OnAfterGetRecord DataItem. Example: We can make calculations for a value that is printed (Bf gross). You can also call NewPage from this trigger to change the page. With CurrReport.SKIP can skip the iteration of the DataItem.

57. Reports (and IV)


Before showing a section OnPreSection runs. Example: We want to show the section or not (SHOWOUTPUT function), or perform computations for a value printing.

58. Code Units


Where enter code OnRun function: Is created by default with a new codeunit. It is the entry point for execution by default. You can have a record as parameter. Codeunit Functions: If you create a function in a Codeunit can be invoked from other objects: DiaGenTestLin: Codeunit "Dia. Test Gen-line "; DiaGenTestLin. Tester (LinDiaGen)

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

60. Dataports (II)


A Dataport can import data and add them to a table. Example: Add records to a newspaper. Need before starting to learn that "No line will have the first registration of imported

61. Dataports (III)


Before processing a DataItem. Example: A Dataport function is called before invoking the Dataport, then run the Dataport and set a filter on a field of the DataItem. FiltroNoCampaa variable does not lose its value between the two calls is not running CLEAR.

62. Dataports (and IV)


After importing the registry, and before inserting into the table. Example: Seeking a new line number and fill the description field.

63. Common Functions


Other commonly used functions: RESET Delete key selection filters and a variable Record DesdeLMComp.RESET; DesdeLMComp.SETRANGE (LM No. "" No product "); DesdeLMComp.SETRANGE (Type, DesdeLMComp.Tipo:: Product) ('-'); DesdeLMComp.FIND NoSigLin: = "Line No." COUNT Count the number of records. DesdeLMComp.SETRANGE (LM No. "" No product "); DesdeLMComp.SETRANGE (Type, DesdeLMComp.Tipo:: Product) NoCompoLM: = DesdeLMComp.COUNT;

64. Common Functions (II)


COPY Copy a Record variable in another of the same table, active filters and keys. NuevoClie: = COPY (Clie) TRANSFERFIELDS Copy the contents of the fields in a record variable to another that does not have to be of the same table. It takes into account the number of campo.Los fields that do not have matching numbers are set to their default values. RegHasta: = TRANSFERFIELDS (RegDesde)

16 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

65. Common Features (III)


EVALUATE Convert a value from one type to another. Value: = '010196 ', / / type string Ok: = EVALUATE (VarInteger, Value); / / Integer = 10 196 Ok: = EVALUATE (VarDate, Value) / / Date = 010196D FORMAT Convert a value into a string MESSAGE ('Today is% 1', FORMAT (TODAY));

66. Common functions (IV)


Deleteall Delete a series of records in a table LinExtCtaBanco.SETRANGE ("N bank", "N bank"); LinExtCtaBanco.SETRANGE ("No abstract", "No Abstract"); LinExtCtaBanco.DELETEALL; MODIFYALL Modify a number of records in a table CGMov.RESET; CGMov.SETCURRENTKEY ("Account No."); CGMov.SETRANGE ("Account No." CGCta. "No."); CGMov.MODIFYALL ("Account No. ",'');

67. Common functions (V)


COPYFILTER [S] Copy the filters of a type variable to another record in the same table (copy COPYFILTER filters only one field) Clie1.SETFILTER ("No.", '<1000'); Clie1.SETRANGE (Group 1); Clie2.COPYFILTERS (Clie1) Testfield Verify that a field containing a given value. If you omit the second parameter is found to contain a value other than 0 or blank. If this is not true displays an ERROR. Clie.TESTFIELD (Locked, FALSE); Clie.TESTFIELD ("No.");

68. Common functions (VI)


LOCKTABLE Lock one table for transactional processes FIELDNAMES

17 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

Gets the name of a field

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.

72. Dialogues (II)


Posts: Menu options STRMENU STRMENU CASE ('& Insert & Modify, & Delete, & Finish', 4) OF 1: code> to Insertar> 2: code> to Modificar> 3: code> to Borrar> 4: code> to Terminar> Code> for Cancelar> ELSE END;

73. Dialogues (and III)


Posts: Dialog type objects Ventana.OPEN ('# 1 ############################ \' + 'Customer # 2 ############### \' +

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;

74. File Access


Writing to a file: NombArch =''THEN IF ERROR ('Enter the file name. ") CLEAR (FicMovCont) FicMovCont.TEXTMODE: = TRUE; FicMovCont.WRITEMODE: = TRUE; FicMovCont.QUERYREPLACE: = TRUE; FicMovCont.CREATE (NombArch) FicMovCont.WRITE ( STRSUBSTNO ( '# 1 #################### # 2 ####### # 3 ####### # 4 #', COMPANYNAME, FechInicConsol, FechFinConsol, FORMAT (TransfPorDia, 0,2))); FicMovCont.CLOSE;

75. File Access (II)


Read from a file: NombArch =''THEN IF ERROR ('Enter the file name. ") CLEAR (FicMovCont) FicMovCont.TEXTMODE: = TRUE; FicMovCont.OPEN (NombArch) WHILE FicMovCont.POS <> FicMovCont.LEN DO BEGIN FicMovCont.READ (LinTexto) CodEmpr. "Name": = DELCHR (COPYSTR (LinTexto, 1.30 ),'>'); EVALUATE (FechInicConsol, COPYSTR (LinTexto, 32.9)); EVALUATE (FechFinConsol, COPYSTR (LinTexto, 42.9)); EVALUATE (TransfPorDia, COPYSTR (LinTexto, 52.3)); END; FicMovCont.CLOSE;

76. Global Constants System


USERID. ID of the user who logged

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;

77. String Functions


Strpos Position of one string within another COPYSTR Copy a string to another Strlen Size of a String PADSTR Add characters to a String MAXSTRLEN Maximum size of a string LOWERCASE / UPPERCASE Converting to Uppercase / Lowercase

78. String Functions (II)


CONVERTSTR Replaces a character set other, within a string DELCHR Deletes a set of characters within a string INCSTR Increases a string numerically SELECTSTR Returns a substring within a set of strings separated by commas

20 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

STRCHECKSUM Calculates a checksum for a string of numbers

79. Date Functions


DATE2DMY Gets Day, Month or Year from a Date DATE2DWY Gets Day, Week or Year from a Date CALCDATE Calculates a date based on a start date and a DateFormula

80. Date Functions (II)


NORMALDATE Converts a date to "Normal Date" CLOSINGDATE Converts a Date "Closing Date"

81. Math Functions


ABS Absolute Value POWER Power ROUND Rounding RANDOMIZE Plant a seed for the random number generator RANDOM Gets a random number

82. Array Functions


Arrayl Returns the number of array elements COMPRESSARRAY Eliminates white elements of an array of text

21 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

COPYARRAY Copy elements from one array to another

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

86. Code Wizard


It is active in: View / C / AL Symbol Menu (F5) Very useful for non-syntactic errors It shows the variables and fields in addition to the sentences and write the code for us

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

88. BLOB (II)


Control: Picture Box Source Expression: Producto.Imagen

89. Standard Format


Recommended a set of rules to write code so that it is integrated with the existing and can be read easily. Separate with a space either side of a binary operator (+ /: = etc) BIEN y: = (a + b) / 100; MAL y: = (a + b) / 100; Indent two spaces provided. WELL IF a <>''THEN Record.TESTFIELD (b); Use parentheses if and only if there is to change the precedence of operators. Registered WELL IF AND ("No." <>'') THEN x: = a + b

22 of 24

03-08-10 4:38 PM

http://translate.googleusercontent.com/translate_f

ELSE x: = b / (a + b); WRONG IF (a> b) THEN a: = 0;

90. Standard Format (II)


Do not use parentheses in function calls without parameters. WELL RegistrarLnea; MAL RegistrarLnea (); IF and THEN go on the same line. ELSE is on a separate line. WELL IF x = y THEN x: = x + 1 ELSE x: =-x - 1;

91. Standard Format (III)


The additional clauses including an EXIT ELSE should have no part. WELL IF x <> y THEN EXIT (FALSE); x: = x * 2; MAL IF x <> y THEN EXIT(FALSE) ELSE x := x * 2; Cuando BEGIN sigue a THEN o ELSE , va en su misma lnea BIEN IF x = y THEN BEGIN x := x * 2; a := a - 3; END; MAL IF x = y THEN BEGIN x := x * 2; a := a - 3; END;

92. Formateo estndar (y IV)


Expresar las opciones de campos o variables de forma explcita. BIEN IF Tipo = Tipo::Oferta THEN MAL IF Tipo = 0 THEN REPEAT debe ir solo en su lnea y UNTIL debe ir en una lnea acompaado slo de la condicin

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

You might also like