Presentation is loading. Please wait.

Presentation is loading. Please wait.

CodePainter Revolution Trainer Course

Similar presentations


Presentation on theme: "CodePainter Revolution Trainer Course"— Presentation transcript:

1 CodePainter Revolution Trainer Course
Max Vizzini Routine Entities

2 Routine Entities They are used to write procedures or functions.
They do not have a Form associated. A set of portable commands is provided. Commands of the target language can be used. This reduces portability between different programming languages.

3 Routine Painter Developing SW applications you are often required to create procedures and functions to process or check data in managing procedures. The Routine Painter helps you creating and maintaining these procedures and functions that are called inside the various application procedures. The Routine Painter combines flexibility and versatility of C.A.S.E. tools with database oriented instructions, thus offering a user friendly environment. The way how you can add instructions to the entity makes you save time and helps you during the testing of procedures. The possibility to ' collapse ' or ' expand ' instructions blocks/cycles makes the routine more understandable and therefore reduces the error rate. Using the 'Routine Painter' you can create complex processing procedures based on database tables, import/export files and validate data entries.

4 Main Characteristics Istructions are organized in chains.
Chains are subdivided in Blocks. Blocks can be collapsed or expanded. CodePainter generates source code only for the chain starting in the top left corner. Other chains can be “parked” just removing them from the main chain (top left corner). Using the Routine Painter you can ' design ' the procedure/function that must be executed. When the Code is generated the macro instructions defined in the ' design ' phase will be ' expanded ' in source language instructions. N.B. For the MS Visual FoxPro version the created functions are stored during the design phase in a general file (CP_FUNC.PRG). Procedures and functions are similar as they both have one entry and one exit point only. 'Procedures' process data and don't have returns. 'Functions' receive input and return values. The Routine Painter exploits the ' Main Chain ' methodology to identify routines' entry and exit points. The procedures main chain starts with the declaration of variables and ends with the last element. The functions main chain starts with the declaration of parameters and ends with the 'Stop' instruction. The 'Stop' instruction, when used in this context, does not exit the routine but becomes a 'return <value>' returning the result to the function. When you design routines you can define a series of instruction chains . The one positioned in the top left corner is the ' Main Chain ', the only one for which the code is generated. Other instruction chains are used as support where instruction blocks are ' parked ' and not considered during the code generation. This methodology makes development and debugging easy. To exclude instruction blocks from the generated code you simply need to ' take it out ' from the other instructions. You can also ' collapse ' instruction blocks by adding comments on the block's functionalities. This makes routines even more understandable looking like 'Flow Charts'.

5 Database Management Statements
Select Insert Delete Read Write Select From The 'Select' instruction executes a query on the database. The temporary cursor '_curs_<query name>' is created, all records are retrieved and the instructions between 'select’ and 'end select' executed. Insert To Or Delete Records From Tables The 'Insert' and 'Delete' commands open a dialog window in which you can define records that must be added to or deleted from the table. Read Record From table Reads data from a record belonging to the database. Write Record To table Writes data in a record belonging to the database.

6 Flow Control Statements
If/Else Case While B/End 'Case' statement The 'Case' instruction allows adding to the Routine commands like: Case <condition 1> Case <condition 2> Case <condition n> Otherwise EndCase The Conditions are defined in the 'Expression' area. In order to add or cancel conditions you need to open the menu on the tab-strip right clicking on the tab-strip name. 'While' Statement The 'While' instruction allows you to add interactions to the routine: While <condition 1> ... EndWhile Instructions added to the 'While' branch are executed until the condition defined in the in the 'Expression' property is 'false'. Begin/End comments The 'Begin/End' command groups instructions that perform a functionality that can be seen as a single command. It is similar to a procedure but has a less important meaning and it is easier to use. To display Begin/End instructions you simply need to expand the branch. To display procedures you need to go to the page or file where the procedure is declared.

7 Error Management Statements
Try/Catch Raise Stop 'Raise' Statement The 'Raise' instruction is used to communicate errors. Depending on where the instruction is placed it impacts the sequence in which the Routine is executed: 'Raise' in the 'Try' branch of the 'Try/Catch' instruction: the routine execution passes on to the 'Catch' branch and the error message defined in the 'Error expression' property is displayed. 'Raise' anywhere else: the execution of the current page is terminated. Unlike the 'Stop' instruction 'Raise' displays the error message defined in the 'Error Expression' property. 'Return' Statement The 'Stop' instruction terminates the routine execution where it has been placed. It can also return a value, but in this case the instruction is called 'Return' and the following is displayed: Return <value to be returned> The value that must be returned is defined in the 'Return Expression' property. The 'Context Lists' can be displayed with the 'Advanced' button and using editing tools you have an overview of the properties and objects available in CodePainter's project. The 'Return' instruction, i.e. 'Stop' + 'return value' is considered only when the function template DBBAPF is set in the routine.

8 Declarations, Remarks & Exec Statement
Var Rem Exec Var This dialog window allows to declare variables, define values or call methods and set properties for variables pointing to objects. In routine procedures the 'w_' rule is not applied. You can define variables having the prefix 'w_' but the string will not be automatically added as happens in the other painters. Local Var Defines whether the defined variable is local to the routine or must be searched in the calling procedure. Parameter Routine parameter. Defines whether the variable is a routine parameter. Parameters are initialized from the calling procedure. Routines generated with CodePainter have two ways of communicating with the calling procedure, namely using parameters or global variables. In the first case the calling procedure must define the values while it calls the routine and cannot receive return values. In the second case the calling procedure creates a local variable. The routine must declare a variable with the same name as the local variable and set the variable flag to local. This enables to transfer data back and forth between the routine and the calling procedure. Exec Definition The 'Exec' instruction is used to write instructions, commands, dialogs etc., i.e. all those elements that don't find 'place' within other instructions. Usually these instructions are made by a 'single row' and are not bound to the database and transaction management.

9 Example of a Multiple Page Routine


Download ppt "CodePainter Revolution Trainer Course"

Similar presentations


Ads by Google