Macros&Events User Guide
Macros&Events User Guide
Macros&Events User Guide
Macros:
A macro is a script containing a sequence of commands that can be initiated with a single
command button or event.
Macros are useful for customizing your forms in any number of ways. For instance, you can save
time and effort for your users by defining a series of steps that execute automatically with a
single click. You can use a macro to automatically validate user input before it is entered in the
table. You can automate complex surveys with many branches using conditional (if-then-else)
logic. You can even make your forms dynamic by having macros execute automatically when a
given event occurs, such as when the form opens or the user changes a field value.
Components of a Macro:
A macro consists of a sequence of commands that you want performed in a given order.
Cellica Database offers a large library of commands that you can use as steps in a macro.
Most commands have parameters you must specify, such as values read into or written out by
the command. For these values, you can supply a constant or an expression. Expressions can
read values stored in a table column for the current record as well as apply mathematical
operations, if-then-else logic, and functions to return a desired value.
The script commands can execute in a straight linear sequence, or you can incorporate skips,
branches and loops based on conditional logic using Skip commands. You can also have
SubMacros within a Macro. SubMacros are a sequence of commands that you write once,
and can then call from the main script as many times as needed. Simply write the SubMacros as
you would any other, then call it from the main script using a "Run macro" command.
One Cellica Database form can have any number of macros. However, each macro is "built
into" a single Cellica Database form; it is not possible to call an external macro.
Create a Macro:
Create a new form or open an existing form using Edit Form option on File Manager.
Click on Macros present in the FormsForm and Tab Properties control.
_____________________________________________________________________________________
Cellica Database Macros and Events
Please Note: You cant use same macro name twice in the current form.
_____________________________________________________________________________________
Cellica Database Macros and Events
_____________________________________________________________________________________
Cellica Database Macros and Events
1) Add Command:
Click on Add Command button to add command to the macro and select the command
you want to use in macro from Command Name drop down list.By default it is added to last.
2) Insert Before:
It used to insert the command before to the selected command in macro steps.
3) Insert After:
It used to insert the command after the selected command in macro steps.
4) Remove selected:
It will remove the selected command from macro steps.
_____________________________________________________________________________________
Cellica Database Macros and Events
5) Remove All:
It will remove all the command from selected macro.
Commands:
Command is a action executed on current form.
For Example: With Set Property command you can set the property of control.
There are two types of commands depending on arguments they needed,
a) Commands with arguments
b) Commands without arguments
For Example: Set property command has three arguments:
1) Property:
List of properties used with control.(Caption, Show/hide Control, Fore Color etc)
2) Control:
List of controls as per property selected in Property.
3) Value:
Required Value to assign to Property of selected Control.
Following commands are supported in Cellica Database Macro builder.
1) Set Property:
Arguments list:
a. Property: Property to set.
(Set Caption, Read Only, Show/Hide Control, Set Font Name, Set Font Size, Set
Forecolor, Set Backcolor, Set Mandatory.)
b. Control Name: Control ID
c. Value: Value for selected property.
Caption, Read Only, Show/Hide Control, Font Name, Font Size, Fore Color, Back
Color, Mandatory.
Use to set a property for a control on a form.
2) Set New List:
Arguments list:
a. Control Name: Control ID
b. List Type :Constant List or Combo Box list
c. Values: Depending on List Type, List of items or set list from another combo
box.
Use this with conjunction with combo box control on form. You can set new list of items or
set list from another combo box to specified combobox control.
_____________________________________________________________________________________
Cellica Database Macros and Events
7) Stop Macro
You can use the "Stop Macro" action to stop the current macro. If included in a
submacro, processing does not return to the main macro. Typically use it when an error
condition is detected.
8) Return From Macro:
Stop the execution of the current macro and return to control process which called it. if
this statement is included in a submacro, processing returns to the main macro. if included in
main macro, processing returns to the form. Recommended as the last step in every macro.
9) Record|First:
Go to first record in the table, based on the current sort order.
_____________________________________________________________________________________
Cellica Database Macros and Events
10) Record|Previous:
Go to previous record in the table, based on the current sort order.
11) Record|Next:
Go to next record in the table, based on the current sort order.
12) Record|Last:
Go to last record in the table, based on the current sort order.
13) Record|Insert: Insert a new record.
14) Record|Delete: Removes current record.
15) Record|Duplicate:
Create a new record by creating a duplicate copy of the current record.
16) Record|Search:
Finds the first record (based on the current sort order) whose value in a specified table
column matches a search value.
If set to False, Message box will show only OK button. When OK button is
pressed the execution of macro will continue from next command.
Expression:
You can assign result by executing expression in command. Expression can be used with three
commands:
1) Assign
2) Select Tab
3) Skip
For Example:
1) $ColumnName*2/10
Column name is prefixed with $ in expression.
2) [TextBox]*2/10
Form control is used In [Control] open and close brackets.
3) 10 * 100/100
Numeric values can be used in expression.
_____________________________________________________________________________________
Cellica Database Macros and Events
User can use "date/datetime/Time" values in these functions by using Constant date in given
format/Column containing datetime value/ControlID of control mapped wit date time type column
1) Now(Flag)
Parameter:
Flag : 0 - Date, 1 - Time, 2 - DateTime
Return current date/time/datetime.
2) DateDiff(date1, date2)
Return the date difference in number of days. (date2-date1)
4) Year (date)
Return the year component of given date.
5) Month(date)
Return the Month component of given date ( integer in the range 1-12).
6) MonthName(date)
Returns the name of the month in given date.
For example, MonthName (14/02/2012) returns February.
7) DayNameOfWeek(date)
Returns the name of the day for datetime.
For example, DayNameOfWeek(14/02/2002) returns Thursday.
8) DayOfMonth(date)
Returns the day of the month for given date (integer in the range 1-31).
9) DayOfWeek(date)
Returns the day of the week for given date as an integer in the range 1-7(where 1 represents
Sunday).
10) DayOfYear(date)
Returns the day of the year for given date as an integer in the range 1-366.
For example, DayOfYear(02/02/2012)returns 33.
14) Hour(datetime)
Returns the hour in datetime as an integer in the range 0-23.
15) Minute(datetime)
Returns the minute in datetime as an integer in the range 0-59.
16) Second(datetime)
Returns the second in datetime as an integer in the range 0-59.
_____________________________________________________________________________________
Cellica Database Macros and Events
String functions
_____________________________________________________________________________________
Cellica Database Macros and Events
Parameters:
First and Fourth parameter: ControlID/ Column Name/ Constant String value/ String
functions.Second and Third parameter: Number constant or length() function.
For example,
- insert(ConvertToString([ControlID]), 0, length($ColumnName), "Abc")
- insert([ControlID], 0, length($ColumnName), $ColumnName)
- insert("XYZ", 0, length("XYZ"), "Abc")
_____________________________________________________________________________________
Cellica Database Macros and Events
5) Length(text)
Returns: the number of characters in text, excluding trailing blanks.
Parameters: ControlID/ Column Name/ Constant String value/ String functions.
For example,
- length(ConvertToString([ControlID]))
- length($ColumnName)
- length([ControlID])
- length("XYZ")
6) Left(text, count )
Returns: a string, with the leftmost count number of characters in text.
Parameters:
First parameter: ControlID/ Column Name/ Constant String value/ String functions.Second
parameter: Number constant or length() function.
For example,
- Left(ConvertToString([ControlID]), 10)
- Left($ColumnName, 5)
- Left([ControlID], 3)
- Left("XYZ", 2)
7) Right(text, count )
Returns: a string, with the rightmost count number of characters in text.
Parameters:
First parameter: ControlID/ Column Name/ Constant String value/ String functions.Second
parameter: Number constant or length() function.
_____________________________________________________________________________________
Cellica Database Macros and Events
For example,
- right(ConvertToString([ControlID]), 10)
- right($ColumnName, 5)
- right([ControlID], 3)
- right("XYZ", 2)
9) Ltrim(text)
Returns: a string, with characters in the text, without leading blanks.
Parameters : ControlID/ Column Name/ Constant String value/ String functions.
For example,
- ltrim(ConvertToString([ControlID]))
- ltrim($ColumnName)
- ltrim([ControlID])
- ltrim(" XYZ")
_____________________________________________________________________________________
Cellica Database Macros and Events
10) Rtrim(text)
Returns: a string, with characters in the text, without trailing blanks.
Parameters : ControlID/ Column Name/ Constant String value/ String functions.
For example,
- rtrim(ConvertToString([ControlID]))
- rtrim($ColumnName)
- rtrim([ControlID])
- rtrim(" XYZ")
12) Lcase(text)
Returns: a string, with text as all characters in lowercase
Parameters : ControlID/ Column Name/ Constant String value/ String functions.
For example,
- lcase(ConvertToString([ControlID]))
_____________________________________________________________________________________
Cellica Database Macros and Events
- lcase($ColumnName)
- lcase([ControlID])
- lcase("XYZ ")
13) Ucase(text)
Returns: a string, with text as all characters in uppercase
Parameters: ControlID/ Column Name/ Constant String value/ String functions.
For example,
- ucase(ConvertToString([ControlID]))
- ucase($ColumnName)
- ucase([ControlID])
- ucase("XYZ ")
_____________________________________________________________________________________
Cellica Database Macros and Events
_____________________________________________________________________________________
Cellica Database Macros and Events
Events:
You can initiate/execute a macro on particular event. You need to select the macro for
particular event.
There are three types of event groups:
a) Form level events
b) Control level events
c) Radio group events
To execute macro on particular event you need to use Event property on one of the above
mentioned event groups.
a) Form Level Event
_____________________________________________________________________________________
Cellica Database Macros and Events
_____________________________________________________________________________________
Cellica Database Macros and Events
_____________________________________________________________________________________
Cellica Database Macros and Events