40
RAP Programming language for the reports generator for OroTimesheet 7 Copyright © 1996-2011 OroLogic Inc. http://www.orologic.com Revision 7.00

RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Embed Size (px)

Citation preview

Page 1: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

RAP

Programming language for the reports generator for OroTimesheet 7

Copyright © 1996-2011 OroLogic Inc. http://www.orologic.com Revision 7.00

Page 2: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Contents

RAP – Programming language for the reports generator for OroTimesheet 7

I

Contents What is RAP ? _______________________________________________________________ 1 Overview of the interface _______________________________________________________ 2 The Calc tab ______________________________________________________________________ 2 The Code Explorer ________________________________________________________________ 2 The Code Editor___________________________________________________________________ 2 New___________________________________________________________________________________ 3 Compile________________________________________________________________________________ 3 Save___________________________________________________________________________________ 3 Revert _________________________________________________________________________________ 3 Delete _________________________________________________________________________________ 3

The Code Toolbox _________________________________________________________________ 3 The Message Window ______________________________________________________________ 3 The Variables View ________________________________________________________________ 3 The Events View __________________________________________________________________ 4 The Module View__________________________________________________________________ 5 Note about the Global section________________________________________________________ 5

Programming with RAP________________________________________________________ 6 Overview_________________________________________________________________________ 6 Procedures and functions ___________________________________________________________ 7 Declaring Local variables __________________________________________________________________ 7 Declaring Local constants__________________________________________________________________ 7 Calling Procedures and Functions____________________________________________________________ 7 Procedure and Function parameters __________________________________________________________ 8

Events ___________________________________________________________________________ 8 Coding an Event Handler __________________________________________________________________ 8 Compiling Event Handlers _________________________________________________________________ 8

Global (Module View) ______________________________________________________________ 8 Programs in RAP ________________________________________________________________________ 8 Declaring Global Variables_________________________________________________________________ 9 Declaring Global Constants ________________________________________________________________ 9 Declaring Global Procedures and Functions____________________________________________________ 9

The Code Toolbox ________________________________________________________________ 10 Overview of the Code Toolbox_____________________________________________________________ 10 Data tab_______________________________________________________________________________ 10 Objects tab ____________________________________________________________________________ 11 Language tab___________________________________________________________________________ 11

Language Reference__________________________________________________________ 13 RAP Language Overview __________________________________________________________ 13

Page 3: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Contents

RAP – Programming language for the reports generator for OroTimesheet 7

II

Statements: ____________________________________________________________________________ 13 Data Types: ____________________________________________________________________________ 13 Enumerated types:_______________________________________________________________________ 13 Operators: _____________________________________________________________________________ 17 Currently Unsupported Elements:___________________________________________________________ 17 Information non available from the Code toolbox ______________________________________________ 17 List of standard colors____________________________________________________________________ 19

Standard Routines ________________________________________________________________ 20 String Functions ________________________________________________________________________ 20 Conversion Functions ____________________________________________________________________ 22 Format Functions _______________________________________________________________________ 24 DateTime Functions _____________________________________________________________________ 30 Math Functions _________________________________________________________________________ 31 Utility Functions ________________________________________________________________________ 34

Page 4: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

What is RAP ?

RAP – Programming language for the reports generator for OroTimesheet 7

1

What is RAP ? RAP (Report Application Pascal) is the programming language that is used into the reports generator for OroTimesheet 7. Most of the time, when you use the reports generator to build your own reports, you don’t have to use RAP. However, using RAP allows you to create more dynamics reports. For example, you can use RAP to display or hide sections of a report depending on the values of specific fields or simply displaying information in different colors or make special calculations when specifics conditions are met. RAP language gives you access to all properties, events, bands, objects and data of the reports. You can even add new objects dynamically into your reports using RAP. The RAP language is an object oriented programming language and is identical to the Delphi’s Object Pascal. If you know Object Pascal, you automatically know RAP. If you don’t know Object Pascal, the RAP programming language will be easy to learn if you already know another programming language. If you don’t know programming, we recommend you to start learning RAP with somebody who knows about programming.

Page 5: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Overview of the interface

RAP – Programming language for the reports generator for OroTimesheet 7

2

Overview of the interface RAP programming is made from the Calc tab when editing a report. The Calc workspace is a development environment that is designed for ease of use. The Code Explorer offers varied views of the report code module; the Code Editor is a syntax-sensitive Pascal editor; the Code Toolbox serves double duty, providing both a partial list of supported identifiers as well as a drag & drop code creation facility. The Calc tab The Calc workspace is the development environment for RAP. The Calc workspace contains the following sections: The Code Explorer, the Code Editor, the Code Toolbox and the Message Window. The Code Explorer The Code Explorer is contained in the upper left and right panes of the Calc workspace. The left pane contains a tree view . Use this to navigate your report's code. The right pane contains a list view. It will display a variety of items depending on what is selected in the tree view. By right clicking on the tree you can display a context menu that allows you to control the behavior of the Code Explorer. If you select Variables, the tree will display the bands of the report. When you click on a band, all variables contained in the band will be displayed. Selecting an individual variable causes the Code Editor to display the OnCalc event handler, if one exists. If you select Events, the tree will display all components in the report. Selecting an individual component allows you to see all of the events for that component. When you select an event, the Code Editor will display the event handler, if one exists. If you select Module, the tree will display module level items: Declarations, Events, Programs (procedures and functions) and Event Handlers. The items displayed in the list view will depend on what is selected in the tree. Likewise, the Code Editor will display code appropriate to what is selected in the list view. With Declarations selected in the tree, the list view will show constants and variables. Select either item to enter declarations in the Code Editor. With Events selected in the tree, the Module level events (OnCreate and OnDestroy) will be shown. Select either to edit the code for these events. With Programs selected in the tree, the list view lists any Module level procedures or functions you have defined. Use the Code Editor to edit these programs. With Event Handlers selected in the tree, the list view displays any events in the report that have handlers assigned. Use the Code Editor to edit these handlers. The Code Editor The Code Editor is the place where you actually write and modify RAP code. This syntax-sensitive editor is similar to the one found in Delphi, with the exception that it displays only one procedure at a time. Whatever the currently selected item is (event handler, procedure, function, variable declarations, etc.), only the code for that item is displayed in the Code Editor. When an item is selected, the editor will either contain the code implementation, or will be blank (if no implementation exists). If no implementation exists, you can create one by clicking in the editor. You can

Page 6: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Overview of the interface

RAP – Programming language for the reports generator for OroTimesheet 7

3

then enter code by either typing or by dragging items from the Code Toolbox and dropping them into the editor. If an item is dropped into the editor over a section of selected code, the selected code will be replaced. The Code Editor's context menu contains the following items: New New has the same effect as clicking in the Code Editor. It is only enabled if there is no implementation for the item currently selected in the Code Explorer. Compile Compile activates the RAP compiler to attempt to compile the current procedure and any procedures upon which the current one depends. Save The Calc workspace maintains an intermediate buffer for the Code Editor. Selecting Save will commit the current contents of the Code Editor to the buffer; it will not save the entire report. Selecting Save has the same effect as navigating away from, and then returning to the current procedure. Revert Use Revert to replace the contents of the Code Editor with what is currently contained in the code buffer. This has the effect of removing all changes since the last save. Delete Select Delete to remove the current procedure entirely. The Code Toolbox The Code Toolbox is a visual code repository. It contains most of the identifiers and code elements that the RAP compiler recognizes. The Code Toolbox enables you to: - View identifiers grouped by available data, visible object properties or language features - Generate code by dragging identifiers into the Code Editor. Functions dragged into the editor will

generate a place-holder parameter list. For example, the following code is generated when you drag the Copy function into the Code Editor:

Copy(S, Index, Count);

Each tab of the Code Toolbox consists of a tree view and a list of identifiers. The tree view allows you to navigate groups of identifiers listed on each tab. Identifiers listed in the Toolbox will also display relevant information such as Type, Size, Signature, etc. The Message Window Messages from the compiler are presented here. You can navigate to the location of compiler errors by double-clicking the error message. The Variables View The Variables view of the Code Explorer is displayed by right-clicking the left pane and selecting Variables from the context menu.

Page 7: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Overview of the interface

RAP – Programming language for the reports generator for OroTimesheet 7

4

This view displays the bands of the report and any variables contained in the currently selected band. Selecting a variable displays the OnCalc event handler, if one exists. The OnCalc handler is presented without the signature, as: Value := For an explanation of the triangular icons which appear on the tree view, see the Events View. The Events View The Events view of the Code Explorer is displayed by right-clicking the left pane and selecting Events from the context menu.

This view displays a listing of all components contained within the report. The right pane displays any events associated with the currently selected component. Selecting an event will display the event handler, if one exists. This view is good for viewing all report objects and their events. In the tree view, you will notice small arrow shaped images to the left of some nodes. These are Compilation State Indicators. They are used to tell you where your code is and what state it is in. There are five possible indicators: - No symbol. Indicates that this component does not have any event handlers assigned, nor does it

contain any components which have event handlers. - White arrow with red border. Indicates that this component does not have any event handlers, but

contains components which do. The red color indicates that one or more of the nested components has event handlers which do not compile.

- Red arrow. Indicates that this component contains event handlers and that somewhere on this branch

there is code that does not compile. If there is no code contained in components below this one, then the problem code is in this component. However, if there is code below this component, the problem may be in a child component's event handlers, in this component's event handlers or both. Note: If a

Page 8: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Overview of the interface

RAP – Programming language for the reports generator for OroTimesheet 7

5

child component's code does not compile, the parent component will still display a red arrow even though its own code may compile.

- White arrow with green border. Indicates that this component does not have any event handlers

assigned, but contains other components which do. The green color indicates that the event handlers of the contained components have compiled successfully.

- Green arrow. Indicates that this component has event handlers assigned. The green color indicates

that these event handlers, and any assigned to components nested within this one, have successfully compiled.

The Module View The Module view of the Code Explorer is displayed by right-clicking the left pane and selecting Module from the context menu.

This view displays items which are visible to all event handlers of the report: - Declarations: These are variables and constants that are globally visible throughout the report. - Events: These are, in essence, the report's events. OnCreate and OnDestroy fire when the report is

created and closed, respectively. OnCreate and OnDestroy are good places for initialization and finalization code such as creating and freeing objects and initializing variables.

- Programs: These are procedures and functions that are globally visible throughout the report and can

therefore be called from any event handler. - Event Handlers: These are all event handlers that have been implemented in the report. Note about the Global section Items declared in the Global section of a report are effectively visible throughout the report and to all child subreports. When compiling, the compiler tries to resolve all references within the current module. If it can't find an identifier, it begins looking in the next parent report's global section and continues this up to the main report.

Page 9: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

6

Programming with RAP Overview When displaying and/or printing reports, some events are always fired. You can write lines of code to make specific actions or calculations when these events are fired. For example, when you print a report, an event called OnPrint is fired before printing each object of the report. For example, if into your report you have an object which prints an amount, you could use the OnPrint event of this object to write some lines of code to indicate which color the amount will be printed depending of its value. For example, if the amount is less than zero, you could print the amount in red and in black if the amount is equal or greater than zero. Here is an example of RAP of how you could do this (We suppose that the amount object is named MyAmount) : If MyAmount.FieldValue < 0 Then MyAmount.Font.Color := clRed Else MyAmount.Font.Color := clBlack; The first line check if the value of the MyAmount object is less than 0. Its done by using the FieldValue property of the MyAmount object. If the value is less than 0, the program automatically jump to the line 2. If the value is not less than 0, the program automatically jump to the line 4. When programming with RAP, the red color is called clRed and the black color clBlack. The color is affected to the “Color“ property of the “Font“ property of the MyAmount object. The Font property represents the font to use for this object while the “Color“ property indicate the color to use for the font. Each object of a report have properties, events and methods. A property is a specific characteristic of an object. For example, the “Font“ property of the MyAmount object indicate the font to use for this object. These properties can have themselves properties like the Color property of the Font property of the MyAmount object. An event is an action automatically fired at a given time. You can uses events to interact with your report. For example, the OnPrint event of the MyAmount object is fired each time the MyAmount object is printed. A Method is a procedure or function associated to an object such as the Free method of the MyAmount object. Typing the following line of code, MyAmount.Free; will free the MyAmount object. Note that most of the time, only the Create and Free methods will be used to add or remove objects dynamically to your reports. In addition to report’s objects, each band and the report itself have their own properties, events and methods. To know events of an object, from the Calc tab, select the desired object from the Report objects section and the available events of this object will be displayed in the Events section. To know properties and methods of an object, from the Calc tab, select the desired object from the Code Toolbox: Report objects section and the available properties and methods of this object will be displayed in the section below. Note that you can select an object property or method and drag it into the code editor. The code of this object will be automatically generated without typing anything.

Page 10: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

7

Procedures and functions Declaring Local variables Local variable declarations in RAP are just the same as in Object Pascal. To add a local variable declaration to a function, activate the Code Editor for the current item and place the cursor between the function's declaration and the begin. Type var and declare your variables just as you would in Delphi. Example : function MyFunctionTest: Integer; var MyVariable1: Integer; MyVariable2: String; begin ... Declaring Local constants Local constant declarations in RAP are just the same as in Object Pascal. To add a local constant declaration to a function, activate the Code Editor for the current item and place the cursor between the function's declaration and the begin. Type const and declare your constants just as you would in Delphi. Example : function MyFunctionTest: Integer; const MyConstant1 = 25; MyConstant2 = 'This is a test'; begin ... Example 2 (Constants and variables): function MyFunctionTest: Integer; const MyConstant1 = 25; MyConstant2 = 'This is a test'; var MyVariable1: Integer; MyVariable2: String; begin ... Calling Procedures and Functions Calling a function in RAP is no different than in Object Pascal. As long as the function is in scope, you can call it. Note: When calling a parent report's global function from within a subreport, you do not need to qualify the identifier with the parent report's name. In other words, if your Main report has a global procedure,

Page 11: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

8

GlobalDoSomething, and you want to call it from within SubReportA's OnCreate event, you do not have to say Main.GlobalDoSomething. Merely calling GlobalDoSomething will suffice. Procedure and Function parameters Function parameter lists are the same in RAP as in Object Pascal. Note: Because event handlers in RAP cannot apply to more than one event, event handlers in RAP do not have a Sender parameter in their signature. Events Coding an Event Handler In order to code a new event handler, simply select an event in the Code Explorer and click in the white space of the Code Editor. Both the signature and the begin/end pair for the event handler will be generated automatically. You can then begin entering your code. A typical event handler would appear as: procedure Variable1OnCalc(var Value: Variant); begin end; Note: When you are working in the Variables view of the Code Explorer, the event handler signature and begin/end pair will not appear in the Code Editor. You will see only a single line for assigning the Value: Value := In this mode the Code Explorer displays only variables and is, in a sense, equating variables with the value returned by the OnCalc event. Compiling Event Handlers The RAP compiler attempts compilation of the entire module automatically when any of the following happen: - You load a report. - You select the Calc tab within the Report Designer. - You switch views in the Code Explorer. It is also possible to compile the currently selected event handler. To do this, right-click over the Code Editor and select Compile from the popup menu. The compiler will check the global sections and any other programs needed to compile the current event handler. Global (Module View) Programs in RAP All code in a report is contained in the Code Module. The Code Module contains all the event handlers for objects contained in the Report. There is also a global section that can contain module level events,

Page 12: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

9

declarations, procedures and functions. This part of the Code Module is visible from the Module view of the Code Explorer. The programs and variables declared in the global section of a module are visible to all subreport code modules in the report. Declaring Global Variables To declare a global variable, right-click on the Code Explorer and select Module. The tree view will change to display the global section. Click on the Declarations node – this will display two items in the list view: Constants and Variables. Select the Variables item. If you have already declared some variables, they will be displayed in the Code Editor. If the Code Editor is blank, right-click the Variables item and select New – this will activate the Code Editor and add var to the first line. Declare your variables using standard Object Pascal syntax.

Declaring Global Constants To declare a global constant, right-click on the Code Explorer and select Module. The tree view will change to display the global section. Click on the Declarations node – this will display two items in the list view: Constants and Variables. Select the Constants item. If you have already declared some constants, they will be displayed in the Code Editor. If the Code Editor is blank, right-click the Constants item and select New – this will activate the Code Editor and add const to the first line. Declare your constants using standard Object Pascal syntax. Declaring Global Procedures and Functions The global section of the Code Module can contain functions and procedures visible throughout the module and to any subreports below the current report. To declare such functions or procedure, right-click on the Code Explorer and select Module. The tree view will change to display the global section. Click on the Programs node – the list view will display any existent functions and procedures. If you have not declared any, the list view will be empty. Right-click on an empty space in the list view – note that the first two menu items are New Function and New Procedure. Selecting either of these items will create a declaration and an implementation stub.

Page 13: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

10

If you select New Function, a new function named GlobalFunction1 will be added to the list view and the following implementation will be added to the Code Editor: function GlobalFunction1: Variant; begin Result := end; Likewise, if you select New Procedure, a new procedure named GlobalProcedure1 will be added to the listview and the following implementation will be added to the Code Editor: procedure GlobalProcedure1; begin end; The Code Toolbox Overview of the Code Toolbox The Code Toolbox is a visual code repository. It contains most of the identifiers and code elements that the RAP compiler recognizes. The Code Toolbox enables you to: - View identifiers grouped by available data, visible object properties or language features - Generate code by dragging identifiers into the Code Editor. Functions dragged into the editor will

generate a place-holder parameter list. For example, the following code is generated when you drag the Copy function into the Code Editor:

Copy(S, Index, Count);

Each tab of the Code Toolbox consists of a tree view and a list of identifiers. The tree view allows you to navigate groups of identifiers listed on each tab. Identifiers listed in the Toolbox will also display relevant information such as Type, Size, Signature, etc. Data tab The Data tab of the Code Toolbox displays data pipelines and fields, allowing you to drag and drop field references into the Code Editor.

Page 14: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

11

Selecting a pipeline from the list will display all the fields in that pipeline as well as data type and size information for the fields. To insert a field value into the code editing window, select the field and drag it into the Code Editor. The code necessary to retrieve the field value from the pipeline will be generated. For example, dragging a field named 'Name’ from a pipeline named Customers would result in this code: Customers['Name'] Objects tab The Objects tab of the Code Toolbox displays report objects, their properties and methods, allowing you to drag and drop properties and methods into the Code Editor.

Selecting an object from the tree will display a list of that object's properties and methods. To insert a property or method into the Code Editor, select the property or method and drag it into the Code Editor. The code necessary to retrieve the value of the property or call the method will be generated. For example, dragging the 'AutoSize' property from the Code Toolbox pictured above would result in the following code: Label1.AutoSize Language tab The Language tab of the Code Toolbox displays RAP language elements, allowing you to drag and drop elements into the Code Editor.

Page 15: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Programming with RAP

RAP – Programming language for the reports generator for OroTimesheet 7

12

Selecting a category from the tree will display a list of elements for that category. To insert an element into the Code Editor, select the element and drag it to the Code Editor. The code necessary to reference or use the element will be generated. Note that when you drop an item such as a function call, the function's parameter list is provided. For instance, if you drag Copy into the Code Editor, it will expand as: Copy(S, Index, Count);

Page 16: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

13

Language Reference RAP Language Overview RAP is a subset of Delphi's Object Pascal. Most language elements in Delphi are recognized by the RAP compiler and can be found in the Code Toolbox. The following is a list of elements contained in the Toolbox. Statements: Case statements If–then statements If–then–else statements For loops Repeat loops While loops Data Types: Boolean Currency Double Extended Integer Single Char String Date DateTime Time Color Variant Enumerated types: Here is the list of enumerated types used in RAP. To get list of values available for each enumerated type, from the Code toolbox, select the Language tab then click on Enumerated type and select the corresponding enumerated type. Boolean True or False. Example: The following code hide the Label1 object by using its Visible property: Label1.Visible := False; TBrushStyle Determines the pattern painted by the brush (Shape objects). Example: The following code set the brush style of the shape1 object to bsDiagCross: Shape1.Brush.Style := bsDiagCross; See the Brush property section for more information.

Page 17: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

14

TPenStyle Determines the style in which the pen draws lines. Example: The following code set the pen style of the shape1 object to psDot: Shape1.Pen.Style := psDot; See the Pen property section for more information. TAlignment Specifies how text is aligned within an object. Example: The following code set a center alignment to the Label1 object: Label1.TextAlignment := taCenter TppBarCodeType Specifies which symbology to use for a bar code object. Example: The following code set the symbology UPC-A to the BarCode1 object: BarCode1.BarCodeType := bcUPC_A; TppBarCodeOrientation Specifies the orientation of a barcode object. Example: The following code set the orientation of the BarCode1 object from bottom to top: BarCode1.Orientation := orBottomToTop; TppBreakType Specifies what type of component the group can be based upon (Usually specified at design time). Example: Group1.BreakType := btDataField; TppCalcType Not Documented (Usually specified at design time). TppDataType Specifies the type of a variable object. Example: The following code set the type String to the Variable1 object: Variable1.DataType := dtString; TppDBCalcType Specifies the calc type of a dbcalc object. Example: The following code set the type Sum to the DBCalc1 object: DBCalc1.DBCalcType := dcSum;

Page 18: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

15

TppDuplexType Specifies what type of two-sided printing should occur. Note that not all printers support duplex printing (Usually specified at design time or printing time). Example: Report.PrinterSetup.Duplex := dpHorizontal; TppFileType Specifies format of the file when printing to a text file (Usually specified at design time). Example: Report.TextFileType := ftFixedLength; TppFormatType Not documented. TppLanguageType Not documented. TppLinePositionType Specifies the position of a line object. Example: The following code set the position of the line of the Line1 object to top. Line1.Position := lpTop; TppLineStyleType Specifies the style of a line object. Example: The following code set the style of the Line1 object to double line. Line1.Style := lsDouble; TppPassSettingType Specifies how many times a report traverses the data before generating pages (Usually specified at design time). Example: Report.PassSetting := psTwoPass; TppPrintBehaviorType Specifies how a subreport prints within the master report (Usually specified at design time). Example: SubReport1.PrintBehavior := pbChild; TppPrintHeightType Specifies vertical space which will be used when a band is printed (Usually specified at design time). Example:

Page 19: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

16

Header.PrintHeight := phDynamic; TppRangeBeginType Not documented. TppRangeEndType Not documented. TppSaveType Not documented. TppSearchOperatorType Specifies the search operator type. Example: The following code displays a message if the search operator type is Between for the WORDAT search criteria. If Report.AutoSearchCriteriaByName('Timesheets', 'FEUDAT').SearchOperator = soBetween Then ShowMessage('Operator BETWEEN used in the search criteria.'); TShapeType Specifies the shape type. Example: The following code instruct the Shape1 object to display a circle.: Shape1.Shape := stCircle; TppSortOrderType Not documented. TppUnitType Specifies the unit of measure of the report (Usually specified at design time). Example: Report.Units := utInches; TppVarEventType Not documented. TppVarType Specifies the type of a system variable object. Example: The following code set the type of the SystemVariable1 object to displays the page number. SystemVariable1.VarType := vtPageNo; TppPrinterOrientation Specifies the orientation of the report (Usually specified at design time).

Page 20: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

17

Example: The following code set the orientation of the report to Portrait. Report.PrinterSetup.Orientation := poPortrait; TppColumnTraversalType Not documented. TppCrossTabPaginationType Not documented. TppCrossTabChildType Not documented. TppTotalType Not documented. TppNullOrderType Not documented. Operators: Assignment (:=) Boolean (and, not, or, xor) Class (as, is) Math (-, +, *, /, div, mod) Relational (<, <=, <>, =, >, >=) String (+) Unary (-, +) Currently Unsupported Elements: Class declarations Arrays Record types Set types Note: Since RAP doesn't support Set types, properties to TFont have been added to allow you to set these values in code. Normally for a Set type property such as TFont.Style, you might use the Include and Exclude procedures to change its value. In RAP, however, the following boolean properties to TFont have been added for this purpose: Bold, Italic, Normal, Underline and Strikeout. To set a font to bold in RAP, you would say something like MyObject.Font.Bold := True; Likewise to remove style specifications from a font, you would say MyObject.Font.Normal := True; Information non available from the Code toolbox

Page 21: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

18

From the code toolbox, when you select an object, you can see all of its properties. Since properties can also have their own properties, you cannot see those ones since the code toolbox displays only one level of information. For example, from the code toolbox if you select a Label object, you will see all properties of this object. One of these properties is called Font. Since the Font property has its own properties you cannot see those properties from the code toolbox. Here is a list of some properties not available from the code toolbox but you can access with the RAP language: Font property: The font property is used in many object types such as a Label. This property represents the font name to use, the size, the color and the style of the text for the object. Color Color of the font (See the list of standard colors below) Name Name of the font (For example Times New Roman) Size Size of the font Bold If the font is bold (Value True or False) Italic If the font is italic (Value True or False) Underline If the font is underline (Value True or False) Strikeout If the font is strikeout (Value True or False) Normal By affecting the value True to this property, the properties Bold, Italic, Underline and Strikeout will automatically be reset to False. The following example change the font of the MyAmount object for Times New Roman, bold, size of 12 and blue color. MyAmount.Font.Name := 'Times New Roman'; MyAmount.Font.Size := 12; MyAmount.Font.Bold := True; MyAmount.Font.Color := clBlue; Brush property (Shape objects): The Brush property of a shape object represents the color and pattern used to fill the shape. The Brush property has itself two properties: Color and Style. Use the Color property to define the color of the pattern and the Style property to define the pattern (the default pattern is bsSolid). See the TBrushStyle enumerated type to know the list of brush styles (pattern) available.

Page 22: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

19

The following code set the outline color of the shape named Shape1 to red, the brush color to blue and the brush style to diagonal cross lines. (Note that the outline color of the shape is set by the Pen property. See the Pen property section for more information.) Shape1.Pen.Color := clRed; Shape1.Brush.Color := clBlue; Shape1.Brush.Style := bsDiagCross; Result:

Pen property (Shape and Line objects): The Pen property describes the attributes when drawing a line or the outline of a shape. The Pen property has itself the following properties: Color, Style, Width. Use color to specify the color of the pen, the Style to specify the style in which the pen draws lines and Width to specify the width of the pen in pixels. See the TPenStyle enumerated type to know the list of pen styles available. The following code set the pen color of the shape named Shape2 to Fuchsia, the pen style to a dot line and the outline width to 1. Shape2.Pen.Color := clFuchsia; Shape2.Pen.Style := psDot; Shape2.Pen.Width := 1; Result:

List of standard colors clAqua Aqua clBlack Black clBlue Blue clDk Dark gray clFuchsia Fuchsia clGray Gray clGreen Green clLime Lime clLtGray Light gray clMaroon Maroon clNavy Navy

Page 23: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

20

clOlive Olive clPurple Purple clRed Red clSilver Silver clTeal Teal clWhite White clYellow Yellow Note that you can use the RGB function (refer to the Conversion functions section) to get other colors. Standard Routines String Functions Capitalize Declaration function Capitalize(const S: String): String; Description Capitalizes the first character following a space for every word in a string. CompareText Declaration function CompareText(const S1, S2: String): Integer; Description Compares two strings by ordinal value without case sensitivity. Copy Declaration function Copy(S: String; Index, Count: Integer): String; Description Returns a substring of a string or a segment of a dynamic array. Delete Declaration procedure Delete(var S: String; Index, Count: Integer); Description Removes a substring from a string. Insert Declaration procedure Insert(Source: String; var S: String; Index: Integer); Description Inserts a substring into a string beginning at a specified point.

Page 24: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

21

Length Declaration function Length(S: String): Integer; Description Returns the number of characters in a string. LowerCase Declaration function LowerCase(const S: String): String; Description Converts an ASCII string to lowercase. Pos Declaration function Pos(Substr: String; S: String): Integer; Description Returns the index value of the first character in a specified substring that occurs in a given string. Trim Declaration function Trim(const S: String): String; Description Returns a copy of the string S with leading spaces, trailing spaces and control characters removed. TrimLeft Declaration function TrimLeft(const S: String): String; Description Returns a copy of the string S with leading spaces and control characters removed. TrimRight Declaration function TrimRight(const S: String): String; Description Returns a copy of the string S with trailing spaces and control characters removed. UpperCase Declaration function UpperCase(const S: String): String; Description Returns a copy of a string in uppercase.

Page 25: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

22

Conversion Functions Chr Declaration function Chr(X: Byte): Char; Description Returns the character with the ordinal value (ASCII value) of the byte-type expression, X. CurrToStr Declaration function CurrToStr(Value: Currency): String; Description Formats a Currency value as a string. DateTimeToStr Declaration function DateTimeToStr(aDateTime: DateTime): String; Description Converts a TDateTime value to a string. DateToStr Declaration function DateToStr(aDate: Date): String; Description Converts a TDateTime value to a string. FloatToStr Declaration function FloatToStr(Value: Extended): String; Description Converts a floating point value to a string. IntToStr Declaration function IntToStr(Value: Integer): String; Description Converts an integer to a string. RGB Declaration function RGB(bRed, bGreen, bBlue: Integer): Integer; Description

Page 26: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

23

Returns a red, green, blue (RGB) color based on the arguments supplied. The intensity for each argument is in the range 0 through 255. If all three intensities are zero, the result is black. If all three intensities are 255, the result is white. StrToCurr Declaration function StrToCurr(const S: String): Currency; Description Converts a string to a Currency value. StrToDate Declaration function StrToDate(const S: String): Date; Description Converts a string to a TDateTime value. StrToDateTime Declaration function StrToDateTime(const S: String): DateTime; Description Converts a string to a DateTime value. StrToFloat Declaration function StrToFloat(const S: String): Extended; Description Converts a given string to a floating-point value. StrToInt Declaration function StrToInt(const S: String): Integer; Description Converts a string that represents an integer (decimal or hex notation) to a number. StrToIntDef Declaration function StrToIntDef(const S: String; Default: Integer): Integer; Description Converts a string that represents an integer (decimal or hex notation) to a number. If S does not represent a valid number, StrToIntDef returns the number passed in Default. StrToTime Declaration

Page 27: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

24

function StrToTime(const S: String): Time; Description Converts a string to a TDateTime value. TimeToStr Declaration function TimeToStr(aTime: Time): String; Description Returns a string that represents a TDateTime value. Format Functions FormatCurr Declaration function FormatCurr(const Format: String; Value: Currency): String; Description Formats a Currency object. See FormatFloat function fore more information on supported formats. FormatDateTime Declaration function FormatDateTime(const Format: String; aDateTime: DateTime): String; Description Formats a DateTime value. The following format specifiers are supported (See Windows help for more information about date and time formats): Specifier: C Displays the date using the format given by the Windows short date format, followed by the time using the format given by the Windows long time format. The time is not displayed if the fractional part of the DateTime value is zero.

d Displays the day as a number without a leading zero (1-31). dd Displays the day as a number with a leading zero (01-31). ddd Displays the day as an abbreviation (Sun-Sat). dddd Displays the day as a full name (Sunday-Saturday). ddddd Displays the date using the format given by the Windows short date format. dddddd Displays the date using the format given by the Windows long date format.

Page 28: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

25

m Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed. mm Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed. mmm Displays the month as an abbreviation (Jan-Dec). mmmm Displays the month as a full name (January-December). yy Displays the year as a two-digit number (00-99). yyyy Displays the year as a four-digit number (0000-9999). h Displays the hour without a leading zero (0-23). hh Displays the hour with a leading zero (00-23). n Displays the minute without a leading zero (0-59). nn Displays the minute with a leading zero (00-59). s Displays the second without a leading zero (0-59). ss Displays the second with a leading zero (00-59). z Displays the millisecond without a leading zero (0-999). zzz Displays the millisecond with a leading zero (000-999). t Displays the time using the format given by the Windows short time format. tt Displays the time using the format given by the Windows long time format. am/pm Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.

Page 29: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

26

a/p Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly. ampm Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the Windows AM symbol for any hour before noon, and the contents of the Windows PM symbol for any hour after noon. / Displays the date separator character given by the Windows date separator. : Displays the time separator character given by the Windows time separator. 'xx'/"xx" Characters enclosed in single or double quotes are displayed as-is, and do not affect formatting. Format specifiers may be written in upper case as well as in lower case letters--both produce the same result. If the string specified by the Format parameter is empty, the TDateTime value is formatted as if a 'c' format specifier had been given. Example: The following example assigns 'The meeting is on Wednesday, February 15, 1995 at 10:30 AM' to the string variable S. S := FormatDateTime('"The meeting is on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM', StrToDateTime('2/15/95 10:30am')); FormatFloat Declaration function FormatFloat(const Format: String; Value: Extended): String; Description Formats a floating point value. The following format specifiers are supported (See Windows help for more information about number and currency formats): 0 Digit place holder. If the value being formatted has a digit in the position where the '0' appears in the format string, then that digit is copied to the output string. Otherwise, a '0' is stored in that position in the output string. # Digit placeholder. If the value being formatted has a digit in the position where the '#' appears in the format string, then that digit is copied to the output string. Otherwise, nothing is stored in that position in the output string. . Decimal point. The first '.' character in the format string determines the location of the decimal separator in the formatted value; any additional '.' characters are ignored. The actual character used as a the decimal separator in the output string is determined by the Windows decimal separator specified in the Number Format of the International section in the Windows Control Panel.

Page 30: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

27

, Thousand separator. If the format string contains one or more ',' characters, the output will have thousand separators inserted between each group of three digits to the left of the decimal point. The placement and number of ',' characters in the format string does not affect the output, except to indicate that thousand separators are wanted. The actual character used as a the thousand separator in the output is determined by the Windows thousand separator specified in the Number Format of the International section in the Windows Control Panel. E+ Scientific notation. If any of the strings 'E+', 'E-', 'e+', or 'e-' are contained in the format string, the number is formatted using scientific notation. A group of up to four '0' characters can immediately follow the 'E+', 'E-', 'e+', or 'e-' to determine the minimum number of digits in the exponent. The 'E+' and 'e+' formats cause a plus sign to be output for positive exponents and a minus sign to be output for negative exponents. The 'E-' and 'e-' formats output a sign character only for negative exponents. 'xx'/"xx" Characters enclosed in single or double quotes are output as-is, and do not affect formatting. ; Separates sections for positive, negative, and zero numbers in the format string. The locations of the leftmost '0' before the decimal point in the format string and the rightmost '0' after the decimal point in the format string determine the range of digits that are always present in the output string. The number being formatted is always rounded to as many decimal places as there are digit placeholders ('0' or '#') to the right of the decimal point. If the format string contains no decimal point, the value being formatted is rounded to the nearest whole number. If the number being formatted has more digits to the left of the decimal separator than there are digit placeholders to the left of the '.' character in the format string, the extra digits are output before the first digit placeholder. To allow different formats for positive, negative, and zero values, the format string can contain between one and three sections separated by semicolons. - One section: The format string applies to all values. - Two sections: The first section applies to positive values and zeros, and the second section applies to

negative values. - Three sections: The first section applies to positive values, the second applies to negative values,

and the third applies to zeros. If the section for negative values or the section for zero values is empty, that is if there is nothing between the semicolons that delimit the section, the section for positive values is used instead. The following table shows some sample formats and the results produced when the formats are applied to different values: Format string 1234 -1234 0.5 0 0 1234 -1234 1 0 0.00 1234.00 -1234.00 0.50 0.00 #.## 1234 -1234 .5 #,##0.00 1,234.00 -1,234.00 0.50 0.00

Page 31: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

28

#,##0.00;(#,##0.00) 1,234.00 (1,234.00) 0.50 0.00 #,##0.00;;Zero 1,234.00 -1,234.00 0.50 Zero 0.000E+00 1.234E+03 -1.234E+03 5.000E-01 0.000E+00 #.###E-0 1.234E3 -1.234E3 5E-1 0E0 FormatMaskText Declaration function FormatMaskText(const EditMask: String; const Value: String): String; Description Returns a string formatted using an edit mask. Call FormatMaskText to apply the mask specifed by the EditMask parameter to the text string specified by the Value parameter. The edit mask string consists of three fields with semicolons separating them. The first part of the mask is the mask itself. The second part is the character that determines whether the literal characters of the mask are matched to characters in the Value parameter or are inserted into the Value string. The third part of the mask is the character used to represent missing characters in the mask. These are the special characters used in the first field of the mask: Character: ! If a ! character appears in the mask, optional characters are represented in the returned string as leading blanks. If a ! character is not present, optional characters are represented in the returned string as trailing blanks. > If a > character appears in the mask, all characters that follow are in uppercase until the end of the mask or until a < character is encountered. < If a < character appears in the mask, all characters that follow are in lowercase until the end of the mask or until a > character is encountered. <> If these two characters appear together in a mask, no case checking is done and the data is formatted with the case present in the Value parameter. \ The character that follows a \ character is a literal character. Use this character to use any of the mask special characters as a literal. L The L character requires an alphabetic character only in this position. For the US, this is A-Z, a-z. l The l character permits only an alphabetic character in this position, but doesn't require it. A The A character requires an alphanumeric character only in this position. For the US, this is A-Z, a-z, 0-9. a The a character permits an alphanumeric character in this position, but doesn't require it.

Page 32: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

29

C The C character requires an arbitrary character in this position. c The c character permits an arbitrary character in this position, but doesn't require it. 0 The 0 character requires a numeric character only in this position. 9 The 9 character permits a numeric character in this position, but doesn't require it. # The # character permits a numeric character or a plus or minus sign in this position, but doesn't require it. : The : character is used to separate hours, minutes, and seconds in times. If the character that separates hours, minutes, and seconds is different in the regional settings of the Windows Control Panel, that character is substituted in the returned string. / The / character is used to separate months, days, and years in dates. If the character that separates months, days, and years is different in the regional settings of the Windows Control Panel, that character is substituted in the returned string. ; The ; character is used to separate the three fields of the mask. _ The _ character automatically inserts spaces into the returned string. Any character that does not appear in the preceding table can appear in the first part of the mask as a literal character. Literal characters are inserted automatically if the second field of the mask is 0, or matched to characters in the Value parameter if the second field is any other value. The special mask characters can also appear as literal characters if preceded by a backslash character (\). The second field of the mask is a single character that indicates whether literal characters from the mask are included in the Value parameter. For example, the mask for a telephone number with area code could be the following string: (000)_000-0000;0;* The 0 in the second field indicates that the Value parameter should consist of the 10 digits of the phone number, rather than the 14 characters that make up the final formatted string. A 0 in the second field indicates that literals are inserted into the Value string, any other character indicates that they should be included. The third field of the mask is the character that appears in the returned string for blanks (characters that do not appear in Value). By default, this is the same as the character that stands for literal spaces. The two characters appear the same in the returned string. FormatString Declaration function FormatString(const EditMask: String; const Value: String): String;

Page 33: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

30

Description Returns a string formatted using an edit mask. See FormatMaskText function. DateTime Functions CurrentDate Declaration function CurrentDate: Date; Description Returns the current date. CurrentDateTime Declaration function CurrentDateTime: DateTime; Description Returns the current date and time. CurrentTime Declaration function CurrentTime: DateTime; Description Returns the current time. DayOfWeek Declaration function DayOfWeek(aDate: DateTime): Integer; Description Returns the day of the week of the specified date as an integer between 1 and 7, where Sunday is the first day of the week and Saturday is the seventh. DecodeDate Declaration procedure DecodeDate(aDate: DateTime; var Year, Month, Day: Integer); Description Breaks the value specified as the Date parameter into Year, Month, and Day values. If the given DateTime value is less than or equal to zero, the year, month, and day return parameters are all set to zero. DecodeTime Declaration procedure DecodeTime(aTime: DateTime; var Hour, Min, Sec, MSec: Integer); Description Breaks a DateTime value into hours, minutes, seconds, and milliseconds.

Page 34: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

31

EncodeDate Declaration function EncodeDate(Year, Month, Day: Integer): DateTime; Description Returns a DateTime value from the values specified as the Year, Month, and Day parameters. The year must be between 1 and 9999. Valid Month values are 1 through 12. Valid Day values are 1 through 28, 29, 30, or 31, depending on the Month value. For example, the possible Day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the Year value specifies a leap year. EncodeTime Declaration function EncodeTime(Hour, Min, Sec, MSec: Integer): DateTime; Description Encodes the given hour, minute, second, and millisecond into a DateTime value. Valid Hour values are 0 through 23. Valid Min and Sec values are 0 through 59. Valid MSec values are 0 through 999. IncMonth Declaration function IncMonth(pDate: DateTime; pNumber: Integer): DateTime; Description Returns the value of the pDate parameter, incremented by the number of months pNumber. pNumber can be negative to return a date n months previous. Math Functions ArcTan Declaration function ArcTan(X: Extended): Extended; Description Calculates the arctangent of a given number. Cos Declaration function Cos(X: Extended): Extended; Description Calculates the cosine of an angle. Cosh Declaration function Cosh(X: Extended): Extended; Description Calculates the hyperbolic cosine of an angle.

Page 35: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

32

Cotan Declaration function Cotan(X: Extended): Extended; Description Calculates the cotangent of an angle. Exp Declaration function Exp(X: Extended): Extended; Description Returns the exponential of X. Frac Declaration function Frac(X: Extended): Extended; Description Returns the fractional part of a real number. Int Declaration function Int(X: Extended): Extended; Description Returns the integer part of a real number. IntPower Declaration function IntPower(Base: Extended; Exponent: Integer): Extended; Description Calculates the integral power of a base value. Ln Declaration function Ln(X: Extended): Extended; Description Returns the natural log of a real expression. Power Declaration function Power(Base, Exponent: Extended): Extended; Description Raises Base to any power.

Page 36: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

33

Round Declaration function Round(X: Extended): Integer; Description Returns the value of X rounded to the nearest whole number. Sin Declaration function Sin(X: Extended): Extended; Description Returns the sine of the angle in radians. Sqr Declaration function Sqr(X: Extended): Extended; Description Returns the square of a number. Sqrt Declaration function Sqrt(X: Extended): Extended; Description Returns the square root of X. Tan Declaration function Tan(X: Extended): Extended; Description Returns the tangent of X. Tanh Declaration function Tanh(X: Extended): Extended; Description Returns the hyperbolic tangent of X. Trunc Declaration function Trunc(X: Extended): Integer; Description Truncates a real number to an integer.

Page 37: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

34

Utility Functions GetInvoiceStatus Declaration function GetInvoiceStatus(iValue: Integer): String; Description Returns the status description of an invoice. iValue can have the value 0 to 4. GetItemStatus Declaration function GetItemStatus(iValue: Integer): String; Description Returns the item status. “Active” if iValue is equal to 1 or “Inactive” if iValue is equal to 0. GetLoggedUserCode Declaration function GetLoggedUserCode: String; Description Returns the employee code of the currently logged user. If the security is not enabled, the function returns “ADMIN”. GetLoggedUserName Declaration function GetLoggedUserName: String; Description Returns the employee name of the currently logged user. If the security is not enabled, the function returns the name specified in the “ADMIN” employee record. GetMonthName Declaration function GetMonthName(piMonth): String; Description Returns the name of the month number received through the piMonth parameter. The result string depends on your Windows language. piMonth can be a value between 1 and 12 representing each month of the year. Example : The following example affects the value “March” to the Caption property of the Label1 object (if the Windows version is English else the month name will correspond to your Windows version language). Label1.Caption := GetMonthName(3); GetShiftDescription Declaration function GetShiftDescription(piNumber: Integer): String;

Page 38: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

35

Description Returns the shift description of a timesheet. piNumber can have the value 0 to 4. GetTimesheetApprovedStatusLabel Declaration function GetTimesheetApprovedStatusLabel: String; Description Returns the label typed for the status “Approved” of a timesheet, in system parameters. GetTimesheetUnapprovedStatusLabel Declaration function GetTimesheetUnapprovedStatusLabel: String; Description Returns the label typed for the status “Non-approved” of a timesheet, in system parameters. GetTimeUnitLabel Declaration function GetTimeUnitLabel: String; Description Returns the time unit label typed in system parameters. GetTimeUnitMaxValue Declaration function GetTimeUnitMaxValue: Double; Description Returns the maximum time units allowed by employee by day that was entered in system parameters. GetUDFCaption Declaration function GetUDFCaption(psModuleCode: String; piCode: Integer): String; Description Returns the label of a user defined field. psModuleCode is the module while piCode is the user defined field number. piCode can have a value of 1 to 12 and psModule can have one of the following values: CUS, ACT, EMP, PRJ, SUBPRJ, TIM, INV. Module code Vs Module Description : Module Description CUS Customers ACT Activities EMP Employees PRJ Projects SUBPRJ Sub-projects TIM Timesheets INV Invoices

Page 39: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

36

Example : The following example affects the user defined field 5 label of the “Customers” module to the “Caption” property of the Label1 object. Label1.Caption := GetUDFCaption('CUS', 5); GetUDFItem Declaration function GetUDFItem(psModuleCode: String; piCode: Integer; pValue: Variant): String; Description Returns the value of a user defined field in a string format no matter the type of the user defined field. If the object type of the user defined field is “List Box” or “Radio Button” the value of the item will be returned instead of the real value of the user field. If the object type of the user defined field is "Checkbox", the value returned will be CHECKED or UNCHEKED. psModuleCode is the user defined field module and piCode is the user defined field number. Refer to the GetUDFCaption function for more information about the psModuleCode and piCode parameters. GetUDFNumericItem Declaration function GetUDFNumericItem(psModuleCode: String; piCode: Integer; pValue: Double): String; Description This function is available for compatibility purpose only. You should now use the new function GetUDFItem. Returns the item description of a user defined field which the object type is “List Box” or “Radio Button” for a field of type numeric, integer or currency (user defined fields 3,4,5,6,7 and 8 of all modules). psModuleCode is the user defined field module, piCode is the user defined field number and pValue is the value of the field. Refer to the GetUDFCaption function for more information about the psModuleCode and piCode parameters. GetUDFObjectType Declaration function GetUDFObjectType(psModuleCode: String; piCode: Integer): Integer; Description Returns an integer that represent the object type of the user defined field. The function will return 1 for an object of type "Edit box", 2 for an object of type "Combo box" or "Radio button" and 3 for an object of type "Checkbox". The function will always return 1 for user defined fields #9,10,11 and 12. psModuleCode is the user defined field module and piCode is the user defined field number. Refer to the GetUDFCaption function for more information about the psModuleCode and piCode parameters. GetUDFStringItem Declaration function GetUDFStringItem(psModuleCode: String; piCode: Integer; pValue: String): String; Description

Page 40: RAP - Programming language for the reports generator for ...downloads.orologic.com/orotimesheet/rap-en.pdf · What is RAP ? RAP – Programming language for the reports generator

Language Reference

RAP – Programming language for the reports generator for OroTimesheet 7

37

This function is available for compatibility purpose only. You should now use the new function GetUDFItem. Returns the item description of a user defined field which the object type is “List Box” or “Radio Button” for a field of type string (user defined fields 1 and 2 of all modules). psModuleCode is the user defined field module, piCode is the user defined field number and pValue is the value of the field. Refer to the GetUDFCaption function for more information about the psModuleCode and piCode parameters. GetWeekDate Declaration function GetWeekDate(piWeekNumber, piDayNumber): Date; Description Returns the date that correspond to the week number and the day number received in parameters. piWeekNumber corresponds to the week number (available from the DATINF table) and piDayNumber corresponds to the day number, 1 being the first day of the week selected in system parameters. piDayNumber can have a value between 1 and 7. Example : The following example will affect the date of the last day of the week to the MyDate1 variable (variable of type Date) for the week corresponding to the date of a timesheet. MyDate1.Value := GetWeekDate(Timesheets['Week Number'], 7); GetWeekNumber Declaration function GetWeekNumber(pdDate): Integer; Description Returns the week number that correspond to a specific date. MessageBeep Declaration procedure MessageBeep; Description Plays a waveform sound. ShowMessage Declaration procedure ShowMessage(const Msg: string); Description Displays a message box with an OK button. The Msg parameter is the message string that appears in the message box.