## Formula Editor window

This window appears when you right-click a formula and select Edit Formula from the shortcut menu in the Catalog Browser. It helps you to add formulas, summaries and parameters and then make certain operations on them according to your requirements. See the window.

The following are details about options in this window:

File menu

- New Formula
  Creates a new formula
- New Summary
  Creates a new summary
- New Parameter
  Creates a new parameter.
- Save
  Saves a formula to the default path
- Save As
  Saves a formula to your specified path.
- Close
  Closes the window.

Edit menu

- Undo
  Undoes an action.
- Redo
  Redoes an action.
- Cut
  Cuts the selected text in the Formula Text panel.
- Copy
  Copies the selected text in the Formula Text panel.
- Paste
  Pastes the text that was previously cut or copied in the Formula Text panel.
- Delete
  Deletes the selected text in the Formula Text panel.
- Search
  Brings out the Find/Replace dialog. You can then search for text in the Formula Text panel, and replace the found text with different text.

View menu

- Fields Panel
  Specifies whether to show the Fields panel.
- Functions Panel
  Specifies whether to show the Functions panel.
- Operators Panel
  Specifies whether to show the Operators panel.
- Sort Tree
  Sorts functions in the Functions panel and fields in the Fields panel by names.

Formula menu

- Check
  Tests the syntax of your formula. If the syntax is incorrect, JReport gives the opportunity to correct the errors.
- Add Bookmark
  Adds a bookmark to a specific position.
- Go to Previous Bookmark
  Goes to the previous bookmark.
- Go to Next Bookmark
  Goes to the next bookmark.
- Clear all Bookmarks
  Clears all of the bookmarks.
- Comment/Uncomment
  Adds or removes comments.
- Add Operators
  Specifies a general operator to be used in the Formula Text panel.
- Color Converter
  A color palette is provided for you to insert the HEX code of a color simply by clicking the corresponding color in the color palette instead of inputting the HEX code manually.
- Auto Finish
  Enables the automatic input of the other part of a sign pair right after you type in the first part when editing formula.
- Properties
  Shows properties of the formula in the Formula Properties dialog.
  - Data Type
    The data type of the returned value of the formula.
  - Precision
    The precision of the returned value of the formula. If the precision is set to 0, all characters of the returned value will be displayed; if it is set to N, only the first N characters will be displayed.
  - Scale
    The number of digits to the right of the decimal point for the returned value of the formula. You can set the scale according to your requirements.

Help menu

- Formula Editor help
  Displays this help document.

Toolbar

The following are commands on the toolbar:

- New Formula
  Creates a new formula.
- New Summary
  Creates a new summary.
- New Parameter
  Creates a new parameter.
- Save
  Saves a formula to the default path.
- Save As
  Saves a formula to your specified path.
- Properties
  Specifies the precision and scale properties of the formula.
- Sort Tree
  Sorts functions in the Functions panel and fields in the Fields panel by names.
- Fields Panel
  Specifies whether to show the Fields panel.
- Functions Panel
  Specifies whether to show the Functions panel.
- Operators Panel
  Specifies whether to show the Operators panel.
- Formula Editor Help
  Displays this help document.
- Cut
  Cuts the selected text in the Formula Text panel.
- Copy
  Copies the selected text in the Formula Text panel.
- Paste
  Pastes the text that was previously cut or copied in the Formula Text panel.
- Delete
  Deletes the selected text in the Formula Text panel.
- Undo
  Undoes an action.
- Redo
  Cancels undoing an action.
- Search
  Opens the Find/Replace dialog to search for text in the Formula Text panel, and replace the found text with different text.
- Check
  Tests the syntax of your formula. If the syntax is incorrect, JReport gives the opportunity to correct the errors.
- Add Bookmark
  Adds a bookmark to a specific position.
- Go to Previous Bookmark
  Goes to the previous bookmark.
- Go to Next Bookmark
  Goes to the next bookmark.
- Clear All Bookmarks
  Clears all of the bookmarks.
- Comment/Uncomment
  Adds or removes comments.
- Add Operators
  Selects a general operator to be used in the Formula Text panel.
- Color Converter
  A color palette is provided for you to insert the HEX code of a color simply by clicking the corresponding color in the color palette instead of inputting the HEX code manually.

Fields panel

Displays a list of those fields that are available for formulas. Those fields contain table columns, formulas, summaries, parameters and special fields. Select one field and double-click it to insert it into the formula text panel at the insertion point.

Functions panel

Displays a list of JReport functions that are available for formulas. When you select one function and double-click it, JReport will insert the selected function into the formula text panel at the insertion point completely with its required syntax items (parentheses, commas, etc). For the usage of these functions, refer to section Built-in functions.

Operators panel

Displays a list of operators that are available for formulas. Select one operator and double-click it to insert the selected operator into the formula text panel at the insertion point. For the usage of these operators, refer to section Operators.

Formula text panel

In this panel, you can build and edit your formula. There are several ways to work with formula:

- Select formula components from the Fields, Functions and Operators panels on the top of Formula Editor, and then double-click the components, JReport will then insert them in the formula;
- Type your formula in the formula text panel directly;
- Use the above two methods together;
- Paste formula text from the text document of other programs.

The line numbers of the formula are marked in the left of the panel to help you check it easily.

###### Related topics:

- Creating a formula