download MORPHX IT, An introduction to Axapta X++ and the MorphX Development Suite by Steen Andreasen (eBook) eBook (PDF), Pages. This book, MORPHX IT, fully illustrate my professional interest in ERP systems and Axapta in particular. My journey through the authoring process has been. this Ebook is really very help full for beginners developers. It contains a basic to high study material, with good examples. This is available in.
|Language:||English, Spanish, Dutch|
|Distribution:||Free* [*Register to download]|
MorphX user interface control element types. Chapter 2 The MorphX development environment and tools. 19 These ebooks are available in PDF,. EPUB. I have created a Morphx report in AX The report looks perfect on the screen , but when print to PDF option of AX is used, we face 2 issues: 1. 4 fields go. MorphX is a simple, free application that will transform (morph) one image into another and create a video that will show this process. Simply drag 2 images to.
The windows can be positioned and resized as required. Do not leave your Axapta client while debugging. When debugging you will transaction lock tables in scope of the code debugged. This will not make you popular if an application user is trying to post data to the locked tables, as the application user will get a database error. The debugger Output window The output window is by default located in the bottom of the debugger.
Here you can monitor the Infolog and print commands sent from the code. Use this window if you have added lines to the Infolog or are printing comments from code for debugging purposes.
Variable window The window is located as the left most window under the debugger window. The window lists the variables in scope of the code window. All types of variables like table fields, types and class are listed. Variables changed between two breakpoints will be highlighted. A neat feature is that you can change the value of any variable while debugging. The lookup field in the top of the variable window is used to pick a method from the call stack.
When selecting a method, the variable window and the debugger window will be updated with the selected stack method. The window gives an overview of the methods processed. You can click any method in the call stack to jump to the method. This will update the debugger window and the variable window. Notice that you cannot jump to a non-overridden system method. A yellow arrow in the left margin indicates the current method being debugged, and if you jump to another method, a green triangle will mark the currently selected method.
Watch window This window is the rightmost in the row under the debugger window. The watch window is used to manually pick variables which you want to trace during the debug session.
The window has three similar tab pages which helps organize the information if you are tracing a lot of variables. To add a variable, mark the variable in the debugger window and drag the variable to the watch window. Use the delete key to remove a variable. As in the variable window, you can change the value of a variable added in the watch window.
While a variable is in scope, the value of the variable is shown. When out of scope, an error is shown as the value for the variable. If a variable is changed between two breakpoints, the value will be highlighted. The variables set in the watch windows will be stored after completing the debug session. This speeds up debugging as you will not have to start all over if you are debugging the same code several times. The compiler window is by default docked in the bottom of the Axapta window.
You can right- click the compiler window, and select No Docking if you prefer having the compiler window to act as a standard window. This will free up more of your working area, especially needed when viewing the property sheet. You can either use the compiler windows or the simpler message window for the compiler result.
With version 3. The message window was used in prior versions. Go to the compiler window and click on the Setup button and choose the Compiler menu item to configure the compiler. The Output defines whether to use the compiler window or the watch window. The watch window shows the same information as the compiler window, with a simpler interface. You can click a line in the watch window to lookup the information. If you have chosen the watch window for the output, you can re-select the compiler window in the top menu at Tools Options by selecting the Compiler button.
The level of compilation checks can be set in the compiler setup window. The field Diagnostic level defines what to include. If set to level 4, best practice checks will be included.
Cross-references will be updated if marked.
Be aware that updating cross-references slows down compiling. A log for the compilation can be made during compilation. However you might be better off just exporting the result of your compilation from the compiler window as you can import the compilation result and then use the features in the compilation window, such as lookup errors and warnings.
The compiler window consists of 4 tab pages. The first tab page shows an overview of the compilation. Depending on the settings, warnings, errors, best practice deviations and tasks will be calculated.
It is recommended practice to compile the entire application before shipping modifications. During a complete compilation, you might notice a huge number of errors and warnings. You do not need to worry, as this is normal. A complete compilation consists of three loops and all objects are not recognized until the final loop. Errors and warnings found during compilation are listed on the second tab page.
The list contains errors and warnings found in methods and the property sheets. Errors are marked with a red symbol, and warnings are with a yellow symbol.
The compiler window is a standard Axapta form, so the standard facilities for sorting and filtering the output are available.
If double clicking an error or warning in the list, the method or property sheet contain the error or warning will be opened. You can then correct the error or warning, save the changes and close the window. As errors and warnings are corrected, they will be removed from the list. If best practice checks have been enabled, the best practice deviations will be listed at the third tab page. Click the button Setup and choose Best Practices in the compiler window to select the best practice checks to be made.
Notice that best practice checks are considered as a guideline. Use common sense while checking the outputs. Missing labels and the use of base types rather than extended types are easy to spot. With the more complex best practice checks, you should not act on the suggestions unless you are familiar with the result of your changes.
The last tab page is used to keep track of your tasks. If you put the text TODO in capitals in a method, the method will pop up in the task tab page during compilation. This is a pretty neat feature, as it helps remember places in the code which must be checked before shipping the modifications.
In the Add-ins menu you will find a menu item called Compile forward. The menu item is available on classes, and will compile all classes inherited from the selected class. This is a quick way to compile before trying out your modifications.
Import and Export You have two options for moving your modification from one system to another. Either copy the whole layer file, or export a selection of objects to a text file. Which option to use depends upon your case. To export a node, right-click the node and select Export. You can export object nodes such as tables, extended data types or forms, or classes, however methods cannot be exported separately.
You can export several objects at once by marking the objects to be exported and right-click one of the marked objects.
A dialog pops up when selecting export. Here you enter a name for the export file. The current layer is exported by default. You have the option to export another layer by selecting a layer in the dialog. This is recommended: Labels used in your code can be exported. Note that importing the exported labels requires knowledge about the label system, so this option is not recommended if the exported file is to be imported by a person without technical skills.
However, exporting labels gives the option to have both code and labels packed in one file. This is handy as nothing is more frustrating than importing a file and realizing that the labels are missing. Objects exported can be locked during the export. The exported objects will be marked with a keyhole icon. This is all very well, but do not expect too much of this, as locked objects can still be modified and everyone can right-click an object and lock or unlock the object.
Often it is difficult to determine what has been locked and why. All object nodes, such as tables, extended data types and classes, have a unique id in the AOT. The id is a sequence number based on the current layer. This id can be included in the exported file. To import an exported file, click the import icon in the AOT tool bar.
Valid files are identified with the extension XPO. Files are imported into the current layer. To check the current layer, look at the right side of the status line in the bottom of the Axapta window.
To get an overview of the imported objects, click on details in the import dialog. A tree view similar to the AOT is shown with the objects in the file. Existing objects in the AOT are marked in bold. By default, all objects in the file will be imported.
You can deselect by clicking the check mark in the tree. For objects that already exist in the AOT, you can compare the object in the file with the object of same name in the AOT.
This is excellent, as you can verify the objects to be updated. For a description of the compare tool, see the section Compare objects. When selecting import of labels, three extra tab pages will be shown in the detail window. Here you can specify the languages of the labels to be imported. The labels in the import file are listed.
You will be notified if the label id is already used in the application. For each label you can choose whether to import it or create a new label id. The default label file used for creating new labels is shown in the upper right corner.
The default label file is set from the labels system. For more information on the labels system, see section Label system. Before choosing the option to delete table and class members during import, you must be sure that you understand this concept. If a table or class is exported, only modified objects of tables and classes are stored in the modified layer, like indexes and methods, not the whole layer of the object.
This means only the methods of a class which are a part of the import file will exist after the import. This goes for the layers to which you have access. If the imported file is exported with AOT id's, you can click the option for importing the object with id. You will need to do a data recovery if you are importing with id and you previously have done an import of a new table without importing the id of the table. You will be notified if changing the id of a table containing data, but you can mark the data recovery check if you are unsure.
Mark the option Overwrite locked objects if you are unsure if any objects imported can be locked. Compare Objects Comparing objects can be done either when importing a XPO file or by right-clicking on an object that exists in more than one layer and choosing Compare from the Add-Ins menu.
When you select to compare two layers, the system will display a compare window. When clicking the lookup button for choosing the layers to compare you might notice that the same layers are listed twice, with one set marked as old layer.
For information on the file structure for an Axapta installation see the manuals in the standard package. Comparing against the old layer is useful if you have done an upgrade to a new service pack of Axapta, and want to check out what modifications have been done to the old layer of an object. The compare window is divided into two panes. In the left side you have the tree view for the object. The right side shows the comparison results for the node selected in the left pane.
The comparison results have the colors red and blue. The colors are used in the result to show the differences between the two layers. Only nodes where there are differences are shown in the tree. The differences in each layer are identified by color. In the tree a blue or a red checkbox indicates that the node only exist in the layer represented by that color.
A two-colored icon indicates that the node is modified in both layers. In figure 8: Comparing two layers of an object, two layers of the form CustTable are compared. In the compare window, lines of code which only exist in one layer are colored with the color representing that layer. A left or right arrow is displayed in the end of a colored line or a colored block of code. By clicking the arrows you can add or remove code to or from the current layer.
This speeds up the process of retrofitting modifications during an update of an application, and is frequently used when you are applying a service pack update. This tool not only compares code, but property sheets as well. Like with code, changes in property values between layers may be migrated using the arrows to update the current layer. Of course there are limitations with the comparing tool: Figure 8: Where the Compare Object tool can be used to compare any type of object, the code upgrade tool is specialized for comparing methods.
This tool is quite handy for comparing changes from an old to a new layer of a service pack or version upgrade. Figure 9: Code upgrade shows a class that has been modified in several layers.
You will see its methods listed in the left side. Methods modified in both the old layer and the new layer will be highlighted, i. When you click on a method modified in more than one layer, Axapta will update the right window with a tab page representing each modified layer.
The first tab page, Workspace will default to show the highest layer. From Workspace you can edit the method. It is preferable to open the code in the editor using the Edit button. In the sub menu Suggestion, the merge buttons will be active if the method is highlighted.
You can use the merge buttons to merge code from all layers to the workspace. This might not complete your upgrade of a method, but it helps having all code in one place. One or two layers will be listed in the sub menu Suggestion. These are the layers the code upgrade tool will suggest to use as offset for the upgrade. Click the layer name to load the layer into the Workspace tab page. The Compare button is used to compare two layers of a method. For highlighted methods, the compared tab pages will automatically be created for layers with differences.
A dialog will pop up, and by default, the search will be done on methods in the current sub tree. Methods matching the search are listed in the grid with the AOT path to the search item. By double clicking you can open the method. You can change the search to also search on properties. Change the search to select All Nodes, and a property tab page will be visible.
The property tab page lists all properties used in the AOT sorted by name. If you want to find forms using a specific property setting, select the property and enter the property value you want to search for. For example, to search for all forms that have the property AlwaysOnTop set, mark the property and enter Yes in the range for the property. Forms where the property is set will be listed.
Notice that you cannot jump to the property sheet by right-clicking. Instead, you right-click the search item and select Properties from the Add-ins menu. The search function used in methods has a find and replace function similar to that in Microsoft Word.
However, if you are going to find and replace code, like changing a variable, you will be better off using the cross-reference tool as it will inform you where an object is used. For information on the cross-reference tool, see Appendix MorphX Tools.
You use the Infolog to inform the user of validations, if an error occurs, or to display information to the user while processing a job. The Infolog is opened in a separate window, and opens automatically when called by a program. Information in the Infolog is removed when the Infolog window is closed, so if you need the information for later use, you can print the contents of the Infolog window by using the print menu item in the top menu.
Information in the Infolog can be triggered both from code and by the kernel. Kernel information typically involves system integrity issues, such as information about mandatory database fields. There are three types of information in the Infolog. The types, which may be identified by the associated icon include: Info text is generally displayed to inform the user about actions being performed by the system.
Warnings and errors typically represent issues that may require action from the user, and may indicate that a process is unable to proceed. If a help page or an action is attached to the information put in the Infolog, the icons will have a mark indicating the extra information.
The first three lines show how to add a simple info, warning and error information. If you are adding a lot of information to the Infolog, you can use the setprefix function to organize the information and make the presentation more user friendly. The above example shows how you can structure a pair of nested loops so as to separately group the content in the Infolog. The prefix for the first Infolog entry represents the outer with separate indented prefixes created for each of the two loops that display info messages.
An entry in the Infolog takes three parameters. The last two parameters are options used for linking to a field in a form, or linking to a help page in the online help. The two last info lines show how to use the optional parameters.
The first links the Infolog entry to the customer parameter form. The system will display this form if the user double clicks on the message in the Infolog.
Notice the optional parameters are always used one at the time as you cannot link to both a form and the help system. Using links in the Infolog is a user- friendly way of communicating with the user; when an error occurs. You can provide the user with information on where exactly to go to fix the problem or provide the user with additional help on how to resolve the error. Unfortunately, changes to these links do not propagate, so if a referenced form field name or help page is changed, you will have to manually maintain any associated links.
The Infolog has a size limit of 10, entries. The Infolog should not be used for reporting detailed status messages representing the normal activity of batch programs. Building an Infolog with several thousand entries takes time and processing resources. You are generally better off using a report. One of the fundamental classes in Axapta is the Info class. The Info class is the handle to the Infolog. For more information on fundamental classes, see the chapter Classes.
The recycle bin can be used to recover objects like tables, extended data types or forms. Parts of an object, like fields of a table or methods of a form, cannot be recovered. You can only recover deleted objects for the current session, as the recycle bin is emptied when the Axapta client is closed. The deleted objects are shown in a list sorted after the objects are deleted, with the last deleted object listed as the first. If an object with the same name has been deleted twice, the objects will appear two times in the list.
Notice that if a table is deleted, the recovered table will not contain any data. These include both general settings and settings that control the development environment. To restore the default settings, use the button Default. For information on the Compiler button, see section Compiler Window. General The General tab page is used to define basic settings like name and password and is where you can setup single sign-ons, so your network account login can be used to automatically login to Axapta.
Status bar The Status bar tab page defines the information to be shown in the status bar located at the bottom line in the Axapta window. The Show util layer field is especially important: When this field is checked the current layer will constantly be displayed. The Warn company accounts change checkbox is also important and is selected by default. When this is marked, Axapta will display a warning message whenever the current company is changed.
Fonts You can set the default font and size to be used at the Font tab page. Normally the standard settings are sufficient. However you can use the font settings if you want another font size for your reports. This is a global setting. If you need a particular font within an individual form or report, you should just change that particular object.
Development It should be no surprise that the Development tab page is of particular interest to developers. It is used to customize the behavior of the development environment. In the General field group you can select a project to be loaded at startup. This is useful when you are working on the same project over an extended period of time, as you do not have to find and open the project manually each time you start your client.
For more information on projects, see the section Projects. The Application object layer field is used to set which layer of information to show in parentheses after the objects in the AOT.
The Show all layers option will give you information on all layers an object is modified in, and can help you understand which objects are stored in each layer. If you want to use the message window to display information regarding tracing or compiling, you might want to adjust the message limit.
When the field Development warnings is checked the system will generate a large number of messages, many of which are of dubious value such as information on selects without an index. If IntelliSense is marked, methods of a current object in the editor will be looked up when a dot is typed after the object name. This is a useful feature and generally should be left on. It will save time when typing code.
For example, when you type in a class name followed by a dot, the methods for the class will be looked up automatically. IntelliSence will also show yellow tooltips with information about base types and parameters when the cursor is position over variables and methods in the editor. The debug mode field is normally set to its default breakpoint. This means if you have set a breakpoint in a method, the debugger will automatically be loaded when a breakpoint is entered. The auto options are used to auto save modified objects.
If auto save is set, objects will be saved at a defined interval. If Auto-refresh is marked, objects created and changed by other developers will automatically be updated.
This is useful when several programmers are working on the same application and one of the programmers is creating a new table or class. The new object will then automatically be available within a defined internal. When not using auto refresh, you will have to restart your Axapta client to see the changes made by other programmers in the AOT.
The garbage collection size should be set, as the number indicates the maximum number of out of scope objects that will be kept in memory. Setting this number to a larger number will tend to consume more memory but consume somewhat less CPU, as the system will run the garbage collection routine less frequently.
The message window is used for printing the trace options. Note, enabling method call will generate a huge number of lines in the message window, as every single method will be listed. If you want the property sheet sorted alphabetically, you can set this field Sort alphabetically. For more information on properties, see section Properties. Mark the SQL trace field to enable tracing. You can define whether you want the tracing result to appear in the message window, the Infolog, the database or written to a file.
You should only use the trace options to optimize your code. Printing the trace information to the screen using the message window or the Infolog gives you a quick way to drill down to the code. By double clicking a trace line, a form will be opened showing information about the traced line; this form allows you to directly edit the code that generated the trace line. Confirmation Confirmation options are important for application users. The different fields indicate the different table groups.
The default settings only require the user to confirm record deletions. When testing the look and feel of an application, it is beneficial to use the same settings as the users. Preload This is a list of tables where all records of the table are cached. For table caching settings, see section Data Dictionary. Tables with few frequently referenced records are often setup to be preloaded. If you have an Axapta installation with a lot of records in one of the preloaded tables, you should consider disabling the preload of this table.
The list is only a default setup and should always be verified for each Axapta installation. Usage data The button Usage data shows stored settings for objects such as forms, reports and runable classes. When a user changes the layout of a form, changes the query of a form or enters values in a report dialog, the settings will the saved.
The usage data is stored in the system table SysLastValue. Only one record exists per object per user, as only the value of the last execution is stored. If you want to see the usage data for all users, you can call the usage data form from Tools Development Tools Application Objects Usage data.
The Usage Data form shows the content of the system table SysLastValue for the current user, divided into tab pages for each type of object. The general tab page has a button to delete all content of SysLastValue for the current user.
This is quite handy if you are going to test your modifications, as you then can start out testing with the same settings as the application user will have the first time a form or report is executed.
Testing modification with usage data stored for the objects is in fact a common source of errors, as an object might act differently with usage data, such as when a range is added to a query. The tab page All usage data lists the objects from all the usage data tab pages.
Notice this tab page will also list usage data for classes. Best Practice This button presents a form which allows the user to set the best practice validation options. By default, all validations will be enabled but you can use the form to disable specific validation checks. Changing the best practice options can also be used if you want to run a single best practice check on all your modifications such as checking for missing labels. For more information on best practice, see the section Compiler Window.
For differentiation, it is referred to as AOT Project. A project is also used to group a subset of the AOT. Objects in a project act the same as they do in the AOT, meaning that you have access to the same property sheet, and identical menus when right-clicking an object. An object may exist concurrently in any number of projects; the objects will still only reside in the AOT.
You should think of project objects as links to AOT object. If an object added to a project is deleted or renamed in the AOT, the link to the AOT object will still exist in the project, and the icon for the object in the project will change. Projects do not provide version control, but grouping your modifications in projects will give you a better overview of which objects have been modified for a new feature.
By segregating a customized application projects you can also facilitate the application upgrade process. Modifying a Project The project window shows the stored projects in a list. To open a project, double click a project node. The selected project will be opened in a new window. The list of available node types includes a special node type, Group, which is used to group objects by type as in the AOT. You can set the type of group like Tables of Forms.
Setting the type of the group will change the icon for the group to match the icon used for the same group in the AOT. When the group type is set, only objects of the specified type can be added.
You might have noticed that the group node has a property called GroupMask. Group masks are used for filtering using wildcards, or which object will be shown for the group.
The icon bar in top of the project window for a selected project is similar to the icon bar in the AOT. With this feature you can export the content of a project. You have an extra filter icon not available on the AOT icon bar. The filter icon is used to build a project based on the filter options chosen. By clicking the Select button in the filter dialog you can select which AOT objects to include.
The filter option will search the system table UtilElements, which contains information of every object in the AOT. For example, if you want to build a project with all object modified in a specific layer, this can be done by setting a range for the field UtilElements. Private projects are only visible to the user who created the project. Shared projects are visible to all users. You should only use private projects for testing purposes or similar tasks.
Using shared projects means that more than one developer can work on the project at the same time. To create a project, right-click the private or shared project node and choose New. Beyond private and shared, there are three types of projects. The first project type just called project is the default project type. By extending the system class ProjectNode, you can create your own project types.
The icon in the project list indicates the type of the project. Additional options can be added to a project type by adding a menu item to the Context menu 1. You should have a basic knowledge of how an Axapta application is structured using a layer technology and how these layers are used by the AOT. This is an object oriented language created to write the logic for the Axapta application.
You might wonder why they created yet another programming language just for Axapta. The language is simple, with integrated SQL syntax, so there is no need to set up and manage data source connections.
Just create your select statement as you would have done using a SQL database query. When adding logic to your forms and reports there are several default methods where you can hook up your logic. You only have a set of system objects where the parameter profiles are visible. This is a great advantage, as you will quickly learn to check the standard package before creating your own modifications from scratch.
Often you might find useful code to get you on right track. The language has a syntax that is similar to Java, combined with the ability to write SQL-like data manipulation statements.
Besides that, you can inherit extended data types, and a set of fundamental classes give the option to make general overloads of the user interface such as changing the behavior of all forms. For a description of the fundamental classes, see the chapter Classes. For more information about jobs, see the chapter Jobs.
The variables are often separated from the code lines with a line only containing a semicolon. This is due to the way the compiler interpreters the code. If you do not add the semicolon you might get an error when compiling.
The semicolon is not needed in all cases, but it is now an accepted Axapta standard to use a semicolon within a method at the end of the data declaration. The reason for this is that the extended data types contain information like string length and whether a string is left- or right- aligned. For more information on extended data types, see chapter Data Dictionary. When naming variables it is considered best practice to use variables names which make sense in the context. For a variable counting customers, name the variable noOfCustomers rather than just a single letter variable like i.
If you used a reserved word for your variable, the compilation will fail.
The syntax for declaring a variable is as the following: CustAccount is of the base type string. First the name of the type is entered, and second a variable name. Note that the line is completed with a semicolon. You can declare more than one variable of the same type in the same statement by separating the variable names with a comma. All the base types are described in figure You can declare more than one variable at the same line like: The compiler will recognize the type of the first variable without any problems.
If one of the following variables, MyCustAccount2 or MyCustAccount3, have the same name as a table or a class, the code will be compiled with errors. If you need to define a constant you must use macros.
For information on macros, see the chapter Macros. For string operations take a look at the functions prefixed with str. Int Numeric values. The functions minInt and maxInt can be used for returning the lowest and the highest integer values.
Real Decimal values. Date Date is counted from the start of year If converted to an integer, the value will be the number of days since start The highest date is end year The Global class has several methods prefixed with date used for date operations. To calculate next and previous date for week, month, quarter and year, check the functions. Timeofday Count the number of seconds from midnight. This is in fact a system type, rather than a base type, but timeofday can be chosen as one of the base types for an extended data type in the AOT.
Enum An enum represents a fixed list of values. To declare enums, one of the enums created in the AOT must be used. One of the most common enums is Boolean, which have the values true and false. Enums have a max of entries.
Container A container is like an array, except a container can hold different base types. Containers are typically used for storing the values of a query.
The functions are prefixed with con. Anytype Anytype is often used in parameter profile, as anytype can be initialized with any of the base types.
Anytype is set to one of the base types when initialized. A common example of anytype is the global method Global:: Figure Some of the base types allow automatic conversion such as setting an integer to a real value.
The compiler will notify you when doing type conversions which loose information. The compiler will also catch an error if you attempt an invalid initialization, like setting an integer to a string value. Here, all variables are initialized at the same time, and printed to screen.
The base type of the variable will be shown as a yellow tooltip. Two different string functions are used for initializing the date and time variables. Notice the notation for initializing an enum. First the enum name is specified, followed by two colons then the entry for the enum. The container variable is initialized with a length of 3.
A container can store any of the base types, even another container. Containers must be accessed using the container functions. Here the first entry in the container is printed. In this example, the variable anytype will be of the type date, as it is initialized with a function returning the current date.
Notice that text is put in quotation marks. It does not matter to the compiler which notation is used. Best practice says that double quotes should be used for text printed to the application users, and single quotes should be used for text only used in the code. Base types can also be declared as arrays. To declare a variable as a dynamic array, add brackets  after the variable name.
You can specify two parameters in the brackets for the array. The first parameter is used to set the array to a fixed length, and the second parameter is used if you have a large array, and only want to hold a part of the array in memory. Entry number one and three of the array are initialized.
When using arrays, the entries do not have to be initialized. You might have noticed the system class Array. If you need an array of the complex types, for example an array of objects, you will need to use the system class Array. The Array class is one of the foundations classes and is described in the chapter Classes. Which can be confusing since the container variable is listed as one of the base types, and a container in MorphX is treated as a base type.
When an object is no longer used, the garbage collector will automatic flush the object and free the memory. The garbage collector can be tuned for special needs for the single login from the top menu Tools Options.
Unary operators require only one operand; binary operators require two operands. The ternary operator, an operator with three operands, is described in the section Control Flow Statements. Operators have a predefined precedence which determines in what order the operators are executed. If an expression uses more than one operator, the predefined precedence is used to determine which order to process the operators. You may use parentheses to overrule the precedence of the operators.
Even though you are aware of the precedence of the operators, you should consider always using parentheses as it makes the code must easier to read. Assignment operators Assignment operators are used to change a value. This could be a variable assignment or just the returned value of a calculation. The operator can also be used as a unary operator as prefix for integer or real values.
If x has the value 0, the complier will throw a division by zero error. The result will round downwards. This is a unary operator. The operator can both be pre-fixed and post-fixed. However the result will not differ whether pre-fixed or post-fixed notation is used. A unary operator. It works the same whether the operator is pre-fixed or post-fixed. Assignment operators Relational operators A relation operator will return true or false for an expression.
This is used for control flow statements as an if-else statement to determine the flow. When selecting data from a table, relation operators are used to limit the number of records fetched. True if x is greater than y. True if x is greater than or equal y.
True if x is less than y. True if x is less than or equal y. True if x is equal y. True is x is not equal y. Often like is used in select statements where records only matching a part of a field must be fetched. This is one of the conditional operators.
Will be true if x and y both are true. True if x or y are true or both x and y are true. This is also and conditional operator, often used to validate two expressions. Will be true if x is false. This is the only unary relational operator. Relational operators Note: This is useful information, as you can optimize your code by placing slow expressions at the right side like an expression which accesses the database. Bitwise operators Bitwise operators are, as the name indicates, used to evaluate expression by using arithmetic and conditional operators at the bit level.
These bitwise operators can only be used with integer values. A common situation for using bitwise operators is as an alternative to having a set of variables setting true or false values if you have to control some access controls with several levels. However the use of bitwise operators will make your code more difficult to read. In fact, the only place you may find yourself using the bitwise operators is when you are interfacing with external applications such as interacting directly with Windows API or need to do any low-level operations on the database.
To be able to understand the result of an expression using bitwise operators, you will have to translate the integer values to binary numbers. This is because 13 and 10 is compared bit by bit and only the bits set for both digits are counted. The expression is translated to binary after the comment.
Only the fourth bit is equal, and thereby the result is 8. The binary value of x will be shifted y positions to the left. This will increase the value of x. The binary value of y will be shifted y positions to the right. This will decrease the value of x. The bits set at the same position for x and y will make the result.
Bits set for x and y will be summed. The bits which are not set at the same position for x and y will make the result. All bits will be reversed. Bitwise operators 2. Often it is necessary to have a block of code executed a number of times or only execute part of the code.
Control flow statements in combination with relational operators are used to set up conditions for how the code is executed.
Loops A loop is used to repeat the same block of code. An expression can be set up for the loop in order to determine the number of times to repeat the loop. An integer variable used to control the number of iterations is set to the value 1.
The while loop will be executed as long as the counter variable is less than or equal to For each loop, a line is printed to the Infolog and the counter variable is increased by 1. The function strfmt is used to format any base type variables into a string. Since the info method only accepts a string as its first parameter, the counter variable is formatted to a string.
The brackets indicate the beginning and end of a block of code. Only code within the brackets will be looped. It is not mandatory to set begin and end brackets, but if the brackets are not added, only the first line of code after the while will be repeated. If the bracket were skipped in this case, the loop would never end. It is considered best practice to always add begin and end brackets, even if a block only contains one line, as it makes the code easier to read. If your need add more lines later, the block of code to be looped is already defined.
For examples on how to use while loops for selecting data, see the section Select statements. The main difference is that a do-while loop will always be executed at least one time, as the condition for the loop is processed after each iteration.
The example shows the same code used in the while loop. Notice that the while clause in a do-while loop must be ended with a semicolon. A for loop has three components contained within parenthesis: For each iteration of the loop, the counter variable is updated based on the incrementing expression.
Braces are used to indicate the scope of the loop. The validation expression is evaluated at the start of each loop. When the validation expression evaluates to false, the loop is no longer executed and control is passed to the statement immediately following the closing brace. It is important that the code within the loop adjust the values evaluated within the validation expression in order for the loop to end.
The for loop used in the example is traversing a container with five elements. The variable counter is initialized to 1 and is used to peek the first element of the container. The block is repeated as long as the counter variable is less than or equal to the length of the container. Conditional Statements Depending on the result of an expression, you often need to execute different parts of code which is the reason for having conditional statements.
In the most simple form, you can use a single if condition, which consists of a relational expression contained in parentheses. If the expression in the if statement is true, the block of code in the if statement is executed. To extend an if statement an else clause can be added. In this case, the else condition will be executed if the expression in the if statement is false.
The above example illustrates the use of an if-else statement. More complex logic can be implemented by nesting if statements. In the example below, a condition has been set for the block of code within the else clause. However, by nesting the second if under the else, the second block will never be validated if the first if statement is true, and thus offers a slight performance advantage.
You can add as many if statements inside each other as needed. But be careful as this can make the program difficult to read and debug. If the number of values is small, a normal if statement is fine, however, if the variable can take on more than two or three values, the list of if statements soon becomes unwieldy. In a switch statement all conditions are added at the same level making the code easy to read and easy to add additional conditions. An expression is set on top of the switch statement which defines the variable to be evaluated.
Following the switch clause are one or more case clauses. Each case clause specifies one or more values separated by commas and terminated by a colon.
September 28, EU: September 24, Retrieved May 17, Retrieved from " https: Action video games Action-adventure games Alien invasions in video games Games about extraterrestrial life Third-person shooters Video games developed in Russia Xbox games Windows games Science fiction video games video games.
Hidden categories: Articles with topics of unclear notability from May All articles with topics of unclear notability Products articles with topics of unclear notability Articles using Infobox video game using locally defined parameters Articles using Wikidata infoboxes with locally defined images.
Namespaces Article Talk. Views Read Edit View history. This page was last edited on 29 November , at