Finding Your Way Around The Macro Builder window's controls (see above) are arranged in a logical order that allows you to quickly build the events and actions you require for your Form or control.
» The Code ListBox This is where your constructed code
appears. You can tap on the current line to view and edit the code in the Argument Input boxes. » The Argument Input Boxes
This is where the results of your selections from the Macro Actions List, Conditional/Variables Actions List, Tables,
Field, Functions, Controls, Control Property Attributes and Variables appear. Tapping on any of these DropDown boxes will display a list of actions, tables, functions, etc.
» The Add Code (+) Button
Tapping this button transfers the code from the Argument Input boxes to the Code ListBox. Note:
With SprintDB Pro Ver2.0 and above, the Add(+)
and Update(*) buttons are no longer needed, as
code lines are automatically updated in the Code List
as they are entered. However, you can use the Add(+)
button to duplicate a line of code. » The Delete Line (-) Button
Tapping this button Deletes the currently selected line in the Code ListBox. Note: This action cannot be undone. » The Scroll Statements ScrollBar This allows you to scroll up or down to reveal
Argument Input boxes. Some types of events support more arguments than others, so if this scroll bar is displayed, tap the down arrow to reveal them. » The Up and Down Buttons
Tapping either of these buttons allows you to move the selected line of code up or down in the Code ListBox, thus changing the order in which code is executed. » The Tables Dropdown Box
Selects the required Table from your database inserts it into the Active Input Box. » The Tables (+) Button Tapping this button pastes the currently selected table into the
Active Input Box. » The Fields Dropdown Box
Selects the required Field from a Table and inserts it into the Active Input Box. » The Function Dropdown Box
Selects the required Database Function and inserts it into the Active Input Box. » The Controls Dropdown Box
Selects the Control to add to your expression.
» The Control Property Attributes Dropdown Box
Selects the Attributes you want to associate with the currently selected control. » The Control Property Variabes Dropdown Box
Selects the Local or Global variable you wish to use and inserts it into the Active Input Box. See
Declaring and Using Local and Global Variables.<Index> Building a Macro As noted above, the process of building a Macro
is based on selecting Actions, Tables, Fields and Controls, etc. from the Dropdown boxes. The following examples demonstrate how to construct several different macros. Macro Exercise 1
This simple macro will demonstrate to use a button control to change the BackColor of a Label and have its caption display "Hello World".
- Create a new Database, called "Demo1".
- Create a Table called "Demo1" with 2 fields, with the following structure:
- Fieldname: "Sample" - Type: Text - Size: 20 - Fieldname: "On"
- Type: "Yes/No" - Save the Table.
- Create a New Form..

- Create a large Label control.
- Tap Tools > Control Properties...
- In the Name field, enter the name "lblTarget".
- Set the Fontname to Tahoma, 14 Point, and check the Bold checkbox.
- Tap OK.
- In the Alignment Dropdown box, choose "Center Alignment".
- Tap the OK button to return the Form.
- Create a New Button and place it below the Label.
- Set the Button's properties:
- In the Name field, enter "btnHello".
- In the Caption field, enter "Say Hello"..
- Tap the Event tab.
- Tap the OnClick box then the [...] button. This will open the Macro Builder window.
- From the Macro Actions
list, select "SetControl"
- Tap the + (Add Code) button to add the expression to the list.
- From the Macro Actions list, choose "SetControl".
- Select "lblTarget" from the Controls list.
- This will place "&lblTarget" in the Control box.
- Now select "BackColor" from the Controls Attributes list.
- The Control box will now contain: "&lblTarget.BackColor".
- In the Expression box, enter "65535" or tap the E button and choose Yellow from the Palette dialog.
- Tap the + button to add the Expression.
- From the Macro Actions list, choose "SetControl".
- In the Expression box, enter "Hello World".
- Create another Button and place it underneath the Label on the right..
- Set its caption to "Exit".
- In the Macro Builder, select "CloseForm" from the Macro Actions list.
- Tap the + (Add Code) button.
- Tap the Macro Builder OK button.
At this point you will be able to run your application.
- Tap the File > Run menu item.
- Tap the "Say Hello" button
.
- Tap the "Exit" button to quit.
Macro Exercise 2
At this point you can add a CheckBox control to the Form. This will utilise the "On" field in the "Demo1" table and demonstrate the use of the AfterUpdate event.
- Create a new CheckBox control and place it at the top left of the "lblTarget" control.
- Tap Tools > Control Properties...
- On the Basic tab, set the Name to "chkHello".
- In the Visible field, select "No". This will make the control invisible when the applicaition is run.
- Tap the Data tab and tap the ControlSource [...] button.
- In the Editor box, enter "Demo1.On". This is the name of the Table followed by the Fieldname.
- Tap the OK button.
- Tap the Event tab then tap the AfterUpdate [...] button.
- Select "If" from the
Conditional/Variables Action list.
Tap the Controls list and select "lblTarget". This will place "&lblTarget" into Expression box.
Enter "I am ON!" into the Expression box. Make sure to include the double quotes. Tap the + button.
Now choose SetControl from the Conditional/Variables Action list.
Choose "lblTarget" from the Controls list and then enter "I am ON!" in the Expression box.
The entire code segment is shown below. The column shows you where to enter each line. |