You are on page 1of 41

Release 2

Little templates to
add a lot to your
Clarion applications
2009 Carlos Gutirrez - Sistemas de
Computacin Accesibles del Noroeste, SC

Table of Contents
Introduction .............................................................................................................................. 4
Installation................................................................................................................................ 5
Downloading......................................................................................................................... 5
Installing ...............................................................................................................................6
For users of Release 1 ...............................................................................................................7
Browse to Clipboard to Excel..................................................................................................... 8
What it does .........................................................................................................................8
How to add it to your application ........................................................................................ 10
Template Prompts Reference .............................................................................................. 13
Additional information ........................................................................................................ 14
The Invisible Calculator ........................................................................................................... 16
What it does ....................................................................................................................... 16
How to add it to your application ........................................................................................ 16
Template Prompts Reference .............................................................................................. 17
Additional information ........................................................................................................ 18
Entry controls Cleartype fix and settings ................................................................................. 19
What it does ....................................................................................................................... 19
How to add it to your application ........................................................................................ 19
Template Prompts Reference .............................................................................................. 21
Additional information ........................................................................................................ 22
Auto Next-Tab......................................................................................................................... 23
What it does ....................................................................................................................... 23
How to add it to your application ........................................................................................ 23
Template Prompts Reference .............................................................................................. 25
Additional information ........................................................................................................ 26
Browse Header Sort ................................................................................................................ 27
What it does ....................................................................................................................... 27
How to add it to your application ........................................................................................ 28
Template Prompts Reference .............................................................................................. 30
Additional information ........................................................................................................ 31
Browse Reverse key order....................................................................................................... 32
What it does ....................................................................................................................... 32
SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

How to add it to your application ........................................................................................ 32


Template Prompts Reference .............................................................................................. 33
Additional information ........................................................................................................ 33
Multiple record insert with refresh ......................................................................................... 34
What it does ....................................................................................................................... 34
How to add it to your application ........................................................................................ 34
Template Prompts Reference .............................................................................................. 34
Additional information ........................................................................................................ 34
Refresh window button .......................................................................................................... 35
What it does ....................................................................................................................... 35
How to add it to your application ........................................................................................ 36
Template Prompts Reference .............................................................................................. 36
Additional information ........................................................................................................ 37
Date Range Button .................................................................................................................. 38
What it does ....................................................................................................................... 38
How to add it to your application ........................................................................................ 39
Template Prompts Reference .............................................................................................. 40
Additional information ........................................................................................................ 40
Multi-DLL applications ............................................................................................................ 41
Adding the templates to solutions using multiple applications as dlls .................................. 41

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Introduction
When we deploy a new application and do the training, we like to observe how people interact
with the application. Sometimes we can identify small modifications to our windows that will
save hours to the user. This also applies to the development process, if we find we are doing
something time after time, we must do something to automate it.
Thats how our Micro Templates were born. Some of them save time to the users, and some
save time to the developer.
Youll find that our templates are very simple to implement and to use. Many are global
templates that are populated only once in each application and they do their job in all the
procedures.
If you have an idea for a new template or a new feature, please contact us at:
http://clarion.sca.mx, by mail to: clarion@sca.mx or post it to: http://clarionsca.uservoice.com

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Installation
Downloading
Please visit our site http://clarion.sca.mx and selection the option Downloads Registered
Subscribers. You must be logged in with the user name and password you used when
ordering the subscription, otherwise, the folder will look empty.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Installing
The name of the setup program is SCAMicro2Install.exe; it handles installing and
registering the templates. It detects which Clarion versions you have installed and lets you
choose one. It supports Clarion 5.5, 6.x and the new structure of Clarion 7.x.
The installer can install the templates to Clarion 4 and 5. We havent tested with those version
but they may work. If you find compatibility problems with these versions, please contact us
with the exact problem details and we will try to fix them.
If you have more than one Clarion version installed, just run the setup program again as for
each Clarion installation.
The setup program complies with the Clarion 3rd Party Association standards for Clarion 7 and
Clarion 6 and older.
This table shows the installed files and the actions performed by the setup program (paths
shown are an example; they may be different in your Clarion installation):
Folder\Files

Clarion 6 and older

Clarion 7

Template\
sca2.tpl

C:\Clarion6\3rdParty
\Template

Libsrc\
scainvca.clw scabrwxl.inc
scabrwxl.clw scainvca.inc
Examples\
scaexam.app theexe.app
onedll.app basedll.app
cleartype.bmp
scamicro.dct sca32.ico
scaedit.ico scadelete.ico
scaclose.ico scacancel.ico
scaaccept.ico scaadd.ico
Documentation\
SCA Micro Templates Release
2 Manual.pdf
(This file)

C:\Clarion6\3rdParty
\Libsrc

C:\Program Files\Softvelocity
\Clarion 7\Accessory
\Template
C:\Program Files\Softvelocity
\Clarion 7\Accessory
\Libsrc
C:\Documents and Settings
\All Users\Documents
\SoftVelocity
\Clarion7\Accessory
\SCA\MicroTemplates

Images\
iehand.cur scadrop.ico
scamicrologo.bmp
scarefresh.ico
scacopyexcel.ico
scaexcel.ico
Bin\
SetClarion3rdPartyRed.exe
Addins\
AccessoryMenu.addin
MicroTemplates.addin
SCA.Addin
SCA.resources
Extra Actions:

C:\Clarion6\3rdParty
\Images

C:\Clarion6\3rdParty
\Examples\SCA\MicroTemplates

C:\Clarion6\3rdParty
\Docs\SCA\MicroTemplates

C:\Program Files
\Softvelocity
\Clarion 7\Accessory
\Documents
\SCA\MicroTemplates
C:\Program Files
\Softvelocity
\Clarion 7\Accessory
\Images

C:\Clarion6\3rdParty
\bin
C:\Program Files
\Softvelocity
\Clarion 7\Accessory
\Addins
Template registration

Template registration

RED file configuration:


*.tp? =
%ROOT%\3rdParty\template
*.*
=
%ROOT%\3rdParty\images
*.clw = %ROOT%\3rdParty\libsrc
*.inc = %ROOT%\3rdParty\libsrc

Add links to website and


documentation to the Help
Accessory menu.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

For users of Release 1


Release 1 and Release 2 are two independent template chains. We did it this way because
Release 2 doesnt include the template XP Control enable and the template Auto Next Tab
was restructured to work only as a global template.
So, you can keep all your applications developed with Release 1 that use these features, and
install Release 2 for your new applications.
The template Browse Header Sort in Release 2 is identical to version 1.07 of Release 1.
You can get the latest (1.07) Release 1 version if you have a subscription to Release 2, or just
contact us and we will email it at no cost (please send us your name and the mail address you
used to buy Release 1).
The feature XP Control enable is now included in Clarion 6 and newer (XP/Vista manifest). If
you need this for Clarion 5.5 and Release 2, please download the file XP and Vista manifest for
Clarion 5.5 from the Free Clarion Templates section of our site: http://clarion.sca.mx.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Browse to Clipboard to Excel


What it does
Excel is the new Paper. Many users dont feel they have the information in their hands until
they have it an Excel sheet.
This global extension template adds a menu option to the popup menu (right click) of all the
browses in the application. The menu option copies the browses data to the clipboard, and
prompt the user to automatically paste and format it in a new Excel sheet.

If the user clicks on No, the data can still be pasted manually in the Excel sheet in any
position:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

If you prefer to have the feature more visible to the user, there is a Button Control Template
which can be populated for each browse:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

How to add it to your application


In your application use menu option Application Global Properties (or use the
icon),
then Extensions button Insert, scroll down until you find Browse to Clipboard to Excel
(or type scabrw to use the locator in Clarion 6), and the button Select:

Thats all. The global template detects all browses in the application and adds an option to the
browses popup menu.
If for some reason you need to disable the template for one procedure, open the procedure
Extension, add the extension Browse to Clipboard to Excel and click on the Disable
checkbox:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

If you want to have a button visible near the browse, open the window in the Window
Formatter, click on the Control Template button ( ), select Refresh Window Button, and
then place the button where you want it:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

If the window has two or more browses, youll be prompted to choose the browse to which
the button will be linked before placing the button in the window:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Template Prompts Reference


Global Extension:

Disable: Disables all code generation for this template in all procedures.
Add popup menu option to all browses: Enabled (default) adds a menu option to all browses
in the application. Disabled, it only adds the global class to the application. In this case, the
Button Control Template should be populated to each browse where the feature is wanted.
Menu option text: Text for the popup menu option.
Icon: Icon for the popup menu option.
Procedure Extension:

Disable: Disables all code generation for this template in current procedure.
Button Control Template:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Add popup menu option: This option cant be edited if the global Add popup menu option to
all browses is enabled. If you disable the global option, you can choose if the option is added
to the browses popup menu, or only use the button.

Additional information
If you want to change the text or look of the Paste confirmation dialog, go to Global Properties
Embeds, scroll down until you find SCA Browse to Excel Before Parent Call, click on
Insert, select Source and the Select button:

And paste and edit this code:


IF MESSAGE('Do you want to paste the data in a new Excel book and apply Autoformat?', |!Text
'Paste to Excel?',
|!Title
ICON:Question,
|!Icon
BUTTON:Yes+BUTTON:No,
|!Buttons
BUTTON:Yes)
|!Default
= BUTTON:Yes
RETURN True
ELSE
RETURN False
END

If you dont want a confirmation dialog, paste only this code:


RETURN True

If you dont like the icon the default icon:


there is an alternate one included in the images folder named scacopyexcel.ico:
, or
you can use your own. Change it in the Global Extension or in the Button Control Template
properties.
To read the browse data, the template uses the browse class methods It works with filters and
code in the .validaterecord embeds. It works with Page Loaded or File Loaded browses.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

The Invisible Calculator


What it does
Users of financial applications are constantly using a desktop calculator or the Windows
Calculator to do some simple math operations, and then enter the result in a forms field.
The Invisible Calculator lets them do the math operations directly in the forms field, the user
enters:

And when the Tab key is pressed, it changes to:

How to add it to your application


In your application use menu option Application Global Properties (or use the
icon),
then Extensions button Insert, scroll down until you find Invisible Calculator (or type
scainv to use the locator in Clarion 6), and the button Select:

Thats all. The global template will be enabled for all numeric fields (pictures starting with
@n) in all the windows in the application. It will also work for entry fields in Edit-in-place
browses.
SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

If for some reason you need to disable the template for one procedure, open the procedure
Extension, add the extension Invisible Calculator (procedure) and click on the Disable
checkbox:

Template Prompts Reference


Global Extension:

Disable: Disables all code generation for this template in all procedures.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Procedure Extension:

Disable: Disables all code generation for this template in current procedure.

Additional information
The text typed by the user is passed to Clarion EVALUATE function, so an invalid expression
may return zero. This also means that mathematical functions are available:

Numeric fields with DECIMAL alignment can cause problems if the user enters amounts with
decimals. Its recommended to change them to RIGHT alignment.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Entry controls Cleartype fix and settings


What it does
This is a Global Template that configures some properties of some controls in all the
application, for example, it can make all ENTRY fields FLAT, color REQuired fields, show a hand
( ) cursor when over buttons etc. (check Template Prompts Reference below for a full list).
Also, Clarion 6 and older have a problem with ENTRY field with a Truetype font in computers
where ClearType is enabled:

Windows Vista and Windows 7 enable Cleartype by default in PCs with LCD monitors. Clarion 7
fixes this problem, but as it may take a while for Clarion developers to port all applications to
Clarion 7, this template solves the problem:

How to add it to your application


In your application use menu option Application Global Properties (or use the
icon),
then Extensions button Insert, scroll down until you find Invisible Calculator (or type
scaent to use the locator in Clarion 6), and the button Select:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Thats all. The global template will process al windows in the application. For Edit-in-place
browses it will configure the font of the temporary entry fields created by the ABC classes.
If for some reason you need to disable the template for one procedure, open the procedure
Extension, add the extension Cleartype and Entry controls settings (procedure) and click on
the Disable checkbox:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Template Prompts Reference


Global Extension:

Disable: Disables all code generation for this template in all procedures.
Fix Cleartype for ENTRY/SPIN/DROP/COMBO: Replaces the font of those controls with a
Bitmap font
Bitmap Font: The font to use. It must be a Bitmap font.
Set Flat ENTRY/SPIN/DROP/COMBO/TEXT/LIST: Changes FLAT property for those controls to
True
Set Boxed TEXT: Set the BOXED property for TEXT controls to true
Set color for REQ ENTRY/SPIN/DROP/COMBO/TEXT: Changes the color of those controls if
they have the REQ property. It helps the users to identify what info must be entered before
pressing Accept (i.e. instead of pressing Accept to find out which fields are required).
Color: The color to use for required field. Default is:
Declare ColorReq() procedure: It declares a procedure to update the color of a control if you
change the REQ property programmatically, for example:
IF PO:IsShipped = True
?PO:Address{PROP:Req} = True
ELSE
?PO:Address{PROP:Req} = False
END
ColorReq(?PO:Address)

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Set cursor for BUTTON: Changes the cursor property of all buttons in the application so the
mouse shows a little hand like Internet Explorer:

Cursor: The cursor file to use. IEHAND.CUR is included, but you can choose your own.
Set Icon for WINDOW: Set the icon for all windows in the application:

Icon: The icon file to use. SCA32.ICO is included in the example application, but youll want to
use your own.
Procedure Extension:

Disable: Disables all code generation for this template in current procedure.

Additional information
Code to fix Cleartype is generated but not compiled in Clarion 7

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Auto Next-Tab
What it does
(To avoid confusion, in this text TAB is the controls container inside a SHEET, and Tab is the
keyboard key)
If you have a form with many fields and you organize them in TABs, if the user uses the Tab key
to navigate the controls, when the Tab key is pressed in the last filed of the first TAB, the
cursor goes to the next field after the SHEET, when usually the user wants to go to the first
field of the next TAB.
Standard behavior:

With the template active:

How to add it to your application


In your application use menu option Application Global Properties (or use the
icon),
then Extensions button Insert, scroll down until you find Invisible Calculator (or type
autonex to use the locator in Clarion 6), and the button Select:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Thats all. The global template will check all windows in the application and for windows with
TABs will generate the code.
If for some reason you need to disable the template for one procedure, open the procedure
Extension, add the extension Cleartype and Entry controls settings (procedure) and click on
the Disable checkbox:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Template Prompts Reference


Global Extension:

Disable: Disables all code generation for this template in all procedures.
Using EnterKey?: If you enabled the option Use ENTER key instead of Tab, you have to
enable this option. With this, the template will detect the Enter key in addition to the Tab key
to select the next TAB.
Using EscKey?: If you are using code or a template to let the user go to the previous field using
the Escape key, you have to enable this option.
Procedure Extension:

Disable: Disables all code generation for this template in current procedure.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Additional information
If a window doesnt have a TAB control, it wont generate any code for that window.
If you are using an Enter=Tab template which uses ALIAS, this template wont work. It works
fine with Clarions Use ENTER key instead of Tab which uses PROP:Alert

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Browse Header Sort


What it does
When viewing a browse, the user frequently wants to change the order depending on what is
looking for. This template adds this feature by linking columns in the browse to sort orders
defined in the browses Conditional Behavior.

Clicking again in the de currently selected column, reverses the sort order:

Clicking in another column, changes the sort order and the displayed locator:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

How to add it to your application


1. From your Browse Procedures properties window configure all the sort orders you
want to use using Tables and the Conditional Behavior button. When configuring
additional sort orders, enter 0 (the number zero) in the Condition field:

2. From the same window, select the button Extensions, select your browse, press the
button Insert and select Browse Header Sort:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

3. In the Default Sort Order box, configure the list box column linked to the browses
default sort order, and if you have a Locator, enable and select it:

4. In the Conditional Sort Order box, press the Insert button and select one of the
keys defined in Conditional Behavior and link it to the respective list box column. You
can also configure a locator for this sort order.

5. Repeat for all the sort orders you configured:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Template Prompts Reference

Disable: Disables all code generation for this template.


"Ascending" symbol: Character to add to the list box column header when the column is the
active sort order, and the order is the same as the key.
"Descending" symbol: Character to add to the list box column header when the column is the
active sort order, and the order is the reverse of the key.
"No sort" symbol: Character to add to the list box column header when the column is not the
active sort order. It indicates the column can be clicked to sort.
[+ - ] [ ] [^ v ]: Buttons to configure the previous three fields with preset values.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Single Click on header, DoubleClick on header, CtrlClick on column, ShiftClick on column,


AltClick on column, Other Keys on column: Hotkey to select the column to sort. The default
works fine in most cases.
Default Sort Order: Configuration of the browses default key (Default Behavior).
Column: List box column that matches the key used in the browse.
Symbol at (Left/Right): If the symbol should be added to the left or right of the columns
header.
Using Locator?: Enable if the window has a locator control for the default key.
Locator: Control used as locator for the default key
Alert keys (No|Numbers|Letters|Both): For Page Loaded browses there is no need to alert
keys for incremental locators because the list box usually has the IMM property. For File
Loaded browses this options should be enabled to numbers, letters or both, depending on the
kind of locators being used.
Conditional Sort Order: Configuration of the browses additional sort orders (Conditional
Behavior)
Key: The key defined in the Conditional Behavior entry
Column: The column that matches the key used in the Conditional Behavior entry
Symbol at (Left|Right): If the symbol should be added to the left or right of the columns
header for this sort order.
Using Locator?: Enable if the window has a locator control for this sort order.
Locator: Control used as locator for this sort order.

Additional information
Clarion 6 and newer has a similar feature, but it works using the file driver capability to sort
the information. With big tables this can be a slow process. Using this template instead of
Clarions, you can choose the most efficient key to use for each column for better result.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Browse Reverse key order


What it does
Some information is clearer if presented in a reverse order. For example, for invoices is better
to have the newer invoices at the top of a browse than having to scroll down to the end of the
list. Most file drivers allow defining key with reverse sort order, but its not really needed as
Clarion has a PREVIOUS command which can process files in the reverse key order. This
template does that for browser:

How to add it to your application


From your Browse Procedures properties window select the button Extensions, select your
browse, press the button Insert and select Reverse key order in Browse:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Template Prompts Reference

Disable: Disables all code generation for this template.

Additional information

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Multiple record insert with refresh


What it does
Clarions Form template has the option After successful Insert: Insert Another Record. It
works fine, but has the problem that the browse is not refreshed after each record is added,
and it confuses the users a lot. They have to click Cancel to check which record is already
entered.

How to add it to your application


From your Browse Procedures properties window select the button Extensions, select your
browse, press the button Insert and select Multiple Record Insert with refresh:

Template Prompts Reference

Disable: Disables all code generation for this template.

Additional information
If you were using the option After successful Insert: Insert Another Record, you need to
change it to Return to caller.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Refresh window button


What it does
In networked data entry applications, a supervisor may want to check how the data entry is
progressing. In normal Clarion browse the window must be closed and reopened to force it to
refresh.
This can be solved with a little Refresh button:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

How to add it to your application


Open the window in the Window Formatter, click on the Control Template button (
select Refresh Window Button, and then place the button where you want it:

),

Template Prompts Reference

This template doesnt have any prompt.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Additional information
The template calls ThisWindow.Reset(1), so it refreshes all browses in the window.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Date Range Button


What it does
Reports and processes that ask for a range of dates are very flexible, but entering two dates
can be a lot of work even using popup calendars. This can be solved with a popup menu that
has some commonly used date ranges:

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

How to add it to your application


Open the window in the Window Formatter, click on the Control Template button (
select Fill Date Range Button & Popup and then place the button where you want it:

),

Then right click in the new button and select Actions..

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

In the Actions window, select the controls for the date fields:

Template Prompts Reference

Disable: Disables all code generation for this template.


From control: Control for the initial date in the range.
To control: Control for the final date in the range.
Call ThisWindow.Reset(1): If enabled, the window is refreshed after the user selects one of the
menu options.
POST Accepted: If enabled, EVENT:Accepted is posted to both date controls.

Additional information

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

Multi-DLL applications
Adding the templates to solutions using multiple applications as dlls
The short version: Add the global templates to all the APPs and recompile.
A more precise rule is: Add the global templates to the base dll (your data.dll) and to all the
applications with windows.
Browse extensions and Control Templates (with the exception of Browse to Clipboard to
Excel Button ) dont need a global extension, so they can be added to any procedure in any
application and work fine.
The Control Template Browse to Clipboard to Excel Button needs the global template to be
present in the application, but it cant be populated if it isnt.
The templates detects if your application is part of a Mult-Dll solution by checking application
property Destination Type and the value of the global ABC option Generate template
globals and ABCs as EXTERNAL (symbols %ProgramExtension and
%GlobalExternal). Using these values they decide how to declare, link and export the
needed classes.
In the examples directory there are three apps showing how it works:
basedll.app
onedll.app
theexe.app

A base dll (data dll).


A simple dll in the solution
The solutions main executable.

SCA Micro Templates for Clarion Release 2

2009 Carlos Gutirrez

You might also like