Help Menu

KaioneSoft Home

Help Home

Index

Glossary

Conventions

Introduction

Installation

Getting Started

SprintDB Pro 2

Desktop Companion

Using Tables

Creating SQL

Creating Forms

How to

Advanced Techniques

Database Functions

Understanding Macros »

Macro Actions

Tutorial

UI Design Guide

New Features

Understanding and Using Macros

Overview

SprintDB Pro macros are very similar to the Microsoft Access macro language, although they are  considerably easier to build. Macros allow you to assign Actions and Events to Forms and other controls, for example, Buttons, EditBoxes, CheckBoxes, etc.

A Macro consists of a series of Commands and Statements, similar to BASIC code in many ways, but SprintDB Pro macros also allow you to incorporate Microsoft Pocket Access SQL statements, arguments and functions, some unique to SprintDB Pro.

You can save Macros and later "Call" them to perform just about any function. This makes it easy to create "modules" that can be accessed globally in your application.

Macro Actions Index

Basics

 

Macro Action Reference

Accessing the Macro Builder

Saved Macros

The Macro Builder Window

Calling Macros

Building a Macro

Supported Macro Actions

Accessing the Macro Builder

» For Forms and SubForms

  1. Tap the Tools > Form Properties... menu item.
  2. Tap the Event Tab.
  3. Tap the required Macro Action box.

If you want to create a Macro that you wish to call at runtime, tap the Macro tab. See Saved Macros.

» For Other Supported Controls

  1. Tap the Control you want to create the Macro for.
  2. Tap the Tools > Control Properties... menu item.
  3. Tap the Event tab.
  4. Tap the required Macro Action box.

If a Macro has been assigned to Macro Action box, you will see an Ellipis [...] in the box. In this case you will be able to edit the macro. If there no macro present, tap the Macro Builder Open button [...] .

<Index>

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".

  1. Create a new Database, called "Demo1".
  2. 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.
     
  3. Create a New Form..
  4. Create a large Label control.
  5. Tap Tools > Control Properties... 
  6. In the Name field, enter the name "lblTarget".
  7. Set the Fontname to Tahoma, 14 Point, and check the Bold checkbox.
  8. Tap OK.
  9. In the Alignment Dropdown box, choose "Center Alignment".
  10. Tap the OK button to return the Form.
  11. Create a New Button and place it below the Label.
  12. Set the Button's properties:
  13. In the Name field, enter "btnHello".
  14. In the Caption field, enter "Say Hello"..
  15. Tap the Event tab.
  16. Tap the OnClick box then the [...] button. This will open the Macro Builder window.
  17. From the Macro Actions list, select "SetControl"
  18. Tap the + (Add Code) button to add the expression to the list.
  19. From the Macro Actions list, choose "SetControl".
  20. Select "lblTarget" from the Controls list.
  21. This will place "&lblTarget" in the Control box.
  22. Now select "BackColor" from the Controls Attributes list.
  23. The Control box will now contain: "&lblTarget.BackColor".
  24. In the Expression box, enter "65535" or tap the E button and choose Yellow from the Palette dialog.
  25. Tap the + button to add the Expression.
  26. From the Macro Actions list, choose "SetControl".
  27. In the Expression box, enter "Hello World".
  28. Create another Button and place it underneath the Label on the right..
  29. Set its caption to "Exit".
  30. In the Macro Builder, select "CloseForm" from the Macro Actions list.
  31. Tap the + (Add Code) button.
  32. Tap the Macro Builder OK button.

At this point you will be able to run your application.

  1. Tap the File > Run menu item.
  2. Tap the "Say Hello" button.
  3. 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.

  1. Create a new CheckBox control and place it at the top left of the "lblTarget" control.
  2. Tap Tools > Control Properties...
  3. On the Basic tab, set the Name to "chkHello".
  4. In the Visible field, select "No". This will make the control invisible when the applicaition is run.
  5. Tap the Data tab and tap the ControlSource [...] button.
  6. In the Editor box, enter "Demo1.On". This is the name of the Table followed by the Fieldname.
  7. Tap the OK button.
  8. Tap the Event tab then tap the AfterUpdate [...] button.
  9. Select "If" from the Conditional/Variables Action list.
  10. Tap the Controls list and select "lblTarget". This will place "&lblTarget" into Expression box.
  11. Enter "I am ON!" into the Expression box. Make sure to include the double quotes. Tap the + button.
  12. Now choose SetControl from the Conditional/Variables Action list.
  13. 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.

Cond/Var

Macro Action

Control

Expression

If

 
 

lblTarget = "Hello World"

 

SetControl

lblTarget

lblTarget = "I am ON!"

 

SetControl

lblTarget.BackColor

65535

ElseIf

 
 

lblTarget = "I am ON!"

 

SetControl

lblTarget.BackColor

15000804

 

SetControl

lblTarget

"Off now... Goodbye!"

ElseIf

 
 

lblTarget = "Off now... Goodbye!"

 

SetControl

lblTarget

"I am ON!"

EndIf

 
 
 

When you have entered each line a tapped the + button to add it to the Code list, tap the OK button.

  1. Return to the Form.
  2. Select the "Say Hello" button and add the following line to its OnClick Event:
    -
    SetControl &ChkHello.Visible, True
  3. Run the application: Tap File > Run.
  4. Tap the "Say Hello" button.

This will make the CheckBox visible and lblTarget will have "Hello World!" as its caption. Now tap the CheckBox and see the caption change to "I am ON!". If you tap the CheckBox again, the caption will change to "Off now... Goodbye!"

<Index>

 

 

Saved Macros

SprintDB Pro allows you to create independent or 'stand-alone' macros. These can contain any valid macro actions, events, expressions, etc. and are built as described above. Once a Saved Macro has been created, you will be able to call it at run-time.

Saved Macros are a extremely useful in situations where you need to re-use identical code in more that one place in your application.

You can create up to 5 Saved Macros.

To create a Saved Macro, tap Tools > Form Properties... and then select the Macro tab.

  1. Select a Macro number by tapping an empty Macro box. See below.
  2. Tap the [...] button and enter your code.
  3. Remember to the tap the + button to enter each line.
  4. Tap the OK button to return to the Macro tab.

When a macro exists in a particular box, you will see an Ellipses [...].  To edit the macro, tap the [...] button.

 

Calling Macros

You can Call a Macro from another control's code, for instance, a Button. Use the following method:

  1. In the calling control's Event properties, for instance, OnClick, select CallMacro from the Macro/Actions list.
  2. Choose the Macro number (this is the Name of the Macro) from the Macro list. See Right.
  3. Tap the + button to add the code.
  4. Tap OK.

See also: Tutorial

<Index>