Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: How To (Forms, Reports, and more) > Forms > Technical Documents

Understanding Custom Form Actions

Scroll Prev Top Next More

The R:BASE Form Designer includes a powerful capability to optionally store commands, and use within the forms, in the structure of Custom Form Actions. This functionality allows the ability to build a library of repetitive or common routines and use them on demand when necessary. The entire code in each Custom Form Action is tightly integrated within the Form itself. Copying or unloading the form will carry over the entire code and actions within the form.

 

The entire idea behind this very cool and powerful feature is the ability to build custom code related to the form. In this way, you do not have a separate Custom EEPs, or EEP command files, for controls to keep track of. Anything needed by the form is packaged with it. Retaining the Custom Form Action commands within a form would function almost as a stored procedure for a form.

 

Once Custom Form Actions are defined and saved within the form, any action can be executed with the PROPERTY command within an EEP, or by using a specified keyboard shortcut.

 

Syntax:

 

PROPERTY RBASE_FORM_ACTION <CustomFormActionCommandName> <parameters>

 

Where:

 

CustomFormActionCommandName is the actual name of the "Command Name" field when designing Custom Form Action.

 

Parameters is the optional value(s) you can pass onto the calling command, if required. Use a ' ' blank space with single or double quotes (depending on your database QUOTE settings), if a parameter is not required in calling a command block.

 

Example:

 

1.While in Form Designer, select "Layout" > "Custom Form Actions..." from the form menu bar.
2.Using the Action Designer, assign the Command Name "MyPAUSE" with the action Description "My PAUSE Command".
3.Click on [Add] button to add that action to the list.
4.Highlight the new action and click on the [Edit Command] button to bring up the R:BASE Editor to write the code. While in RBEDIT, you may use [Open] button on the RBEDIT toolbar to import external code to be saved as a Custom Form Action. For this example, copy and paste the following sample PAUSE command syntax:

 

-- My Pause Command

PAUSE 2 USING 'Message Text' CAPTION 'Caption Text' +

ICON INFO BUTTON 'Button Text' OPTION MESSAGE_FONT_NAME MS Sans Serif +

|MESSAGE_FONT_COLOR 0|MESSAGE_FONT_SIZE 10|MESSAGE_FONT_BOLD ON

RETURN

 

5.Click on [OK] button to save the action.

 

6.Repeat the same step for a "MyPRINTCommand" Command Name as you assigned in Steps 2 through 5.

 

-- My Print Command

-- Required Parameters (vReportName,vReportOutput)

 

SET VAR vReportName = .%1

SET VAR vReportOutput = .%2

SWITCH (.vReportOutput)

CASE 'SCREEN'

  SET VAR vReportOption = 'OPTION SCREEN|WINDOW_STATE MAXIMIZED'

  SET VAR vReportFileName = NULL

  SET VAR vReportParameters = NULL

  BREAK

CASE 'PRINTER'

  SET VAR vReportOption = 'OPTION PRINTER'

  SET VAR vReportFileName = NULL

  SET VAR vReportParameters = NULL

  BREAK

CASE 'PDF'

  SET VAR vReportOption = 'OPTION PDF'

  SET VAR vReportFileName = (.vReportName+'.PDF')

  SET VAR vReportParameters = ('|FILENAME'&.vReportFileName)

  BREAK

ENDSW

SET VAR vReportSyntax = ('PRINT'&.vReportName&.vReportOption+.vReportParameters)

RECALC VARIABLES

SET CLIPBOARD .vReportSyntax

PAUSE 2 USING 'Syntax below has also been copied to Windows clipboard.' +

ICON INFO BUTTON 'Use [Ctrl+V] to paste command at the R> prompt or in RBEditor!'

RETURN

 

If you change the "Command Name" or "Description", make sure to click on [Change] button to save the changes.

 

7.Click on [OK] button to save your work and close Action Designer.

 

 

Now you have a form with your own Custom Form Actions to be recycled at will. All you need is the following PROPERTY command to call the Custom Form Actions.

 

With the following Custom Form Actions:

 

MyPAUSECommand

MyPRINTCommand

 

To call MyPAUSECommand in an EEP, use the following PROPERTY command:

 

PROPERTY RBASE_FORM_ACTION MyPAUSECommand ' '

RETURN

 

 

To call MyPRINTCommand in an EEP, use the following PROPERTY command, assuming that you would like to print the report, for example, CustomerList as an PDF document.

 

PROPERTY RBASE_FORM_ACTION MyPRINTCommand 'USING CustomerList PDF'

RETURN

 

 

The last parameter 'USING CustomerList PDF' in the PROPERTY command will be passed on to the MyPRINTCommand Custom Form Action. Notice that MyPRINTCommand requires two parameters. The first parameter CustomerList as %1 will be passed for the variable vReportName and the second parameter PDF as %2 will be passed for the variable vReportOutPut in the MyPRINTCommand Custom Form Action.

 

Notes:

 

Use a blank space to separate multiple parameters as described in above example.

If you change the "Command Name" or "Description" in the Action Designer, make sure to click on [Change] button to save the changes.