You are on page 1of 24

D E L P H I,

L A Z A R U S,
O X Y G E N E,
S M A R T,
A N D
P A S C AL
R E L A T E D
L A N G U A G E S
A N D R O I D,
I O S,
M A C,
W I N D O W S
&

L I N U X

33

SEE DETAILS INSIDE: PAGE 43

6
E
X Y
I
L
H
P
P IM NG
L
DE S S AZI
I M
A
Appmethod

Publisher: Foundation for Supporting the Pascal Programming Language


in collaboration with the Dutch Pascal User Group (Pascal Gebruikers Groep)
Stichting Ondersteuning Programmeertaal Pascal

Google Glass

APPLICATION TETHERING COMPONENTS


EXTEND YOUR EXISTING WINDOWS APPLICATIONS TO MOBILE WITHOUT
HAVING TO PORT YOUR WHOLE WINDOWS APPLICATION. PICK THE FEATURES THAT
MAKE SENSE ON MOBILE AND EASILY INTERACT WITH YOUR EXISTING WINDOWS
APPLICATIONS. CONNECT YOUR DESKTOP (VCL AND FMX) APPLICATIONS AND MOBILE
APPS. CREATE MOBILE COMPANION APPS FOR YOUR VCL APPLICATIONS WORKS VIA WIFI AND ON YOUR LOCAL NETWORK. FUTURE VERSIONS WILL SUPPORT BLUETOOTH.
TASKBAR COMPONENT
COMPONENT FOR PRESENTING PREVIEWS OF MULTIPLE WINDOWS THAT ARE
sELECTABLE IN YOUR APP WITH BUTTON CONTROLS WITHIN THE PREVIEWS AUTOMATIC
OR CUSTOM PREVIEWS SHOW PROGRESS IN THE TASKBAR BUTTON FOR YOUR
APPLICATION OVERLAY ICONS ON TASKBAR BUTTONS
CLOUD SERVICE (BAAS) INTEGRATION WITH COMPONENTS
FOR KINVEY AND PARSE
INTEGRATE WITH LEADING BACKEND AS A SERVICE PROVIDERS
TO ADD FUNCTIONALITY AND PLATFORM SERVICES TO YOUR MOBILE
APPLICATIONS. YOU GET EASY ACCESS TO COMMON SERVICES IN
THE CLOUD WITHOUT HAVING TO BUILD OR MAINTAIN THE BACKEND
SERVICES YOURSELF. USE PUSH NOTIFICATIONS TO ENGAGE YOUR
USERS ON ANY DEVICE OR PLATFORM ACCESS DATA AND OBJECT STORAGE
IN THE CLOUD USER AUTHENTICATION BUILDS ON THE REST CLIENT
SUPPORT INTRODUCED IN XE5. SUPPORTS THE THREE MOST POPULAR BAAS
PROVIDERS KINVEY AND PARSE WITH A COMMON API COMPONENT SET
Professor Dr. Niklaus Wirth
NEW VCL STYLES
GIVE YOUR APPLICATIONS AN UPDATED WINDOWS OR CUSTOM LOOK
INCLUDES A WINDOWS TABLET STYLE SUPPORTS WINDOWS 7
AND WINDOWS 8. FULLY STYLE YOUR APPLICATIONS
INCLUDING MENUS AND BORDERS
VCL SENSOR COMPONENTS
maXbox Starter 5 Start with DLL A Library for All
SENSORS ARE EVERYWHERE, EVEN FOR
WINDOWS USERS WITH NEW WINDOWS
By Max Kleiner
TABLETS LIKE THE SURFACE PRO.NOW YOUR DELPHI APPS CAN
By Rik Smit
Suite
Rays
components
ADD LOCATION, MOVEMENT AND OTHER FEATURES.
ACCESS DEVICE SENSORS FROM VCL APPS
Interview with Pofessor Dr. Niklaus Wirth
RUNNING ON WINDOWS TABLETS
By Max Kleiner
ACCELEROMETER, GPS AND GYROSCOPE FUNCTIONALITY
IN-APP PURCHASE AND IN-APP ADVERTISING
Steps in MindScape AppView Step-By-Step
MOBILE APPS ARE A REVENUE
By Jeroen Pluimers
GENERATING OPPORTUNITY FOR
APPLICATION DEVELOPERS. NOW YOU
New: Delphi XE 6
CAN MONETIZE YOUR MOBILE
Programming
Truth
Table reduction
APPS BY INTEGRATING IN-APP PURCHASE
By David Dirkse
FUNCTIONALITY AND ADVERTISING.
SELL CONTENT, FUNCTIONALITY, SERVICES
Databases for XE6
AND SUBSCRIPTIONS ON IOS AND ANDROID
By Cary Jensen
SUPPORTS THE TOP AD NETWORKS
(GOOGLE ADMOB AND APPLE IAD)
Updating
DotTapper
CREATE APPS FOR GOOGLE GLASS
By Jeremy North
MULTI-DEVICE APPLICATION
DEVELOPMENT WITH DELPHI
Six new ready to use components!
NOW EXTENDS BEYOND PCS,
By Fikret Hasovitch
TABLETS AND SMARTPHONES TO WEARABLES.CREATE ANDROID
APPS THAT RUN ON GOOGLE GLASS.NEW CUSTOM STYLE WITH GOOGLE GLASS
OPTIMIZED LOOK AND RESOLUTION GOOGLE GLASS DEVICE DESIGNER TEMPLATE
ACCESSIBILITY
MAKE YOUR APPLICATIONS EASIER TO USE FOR MORE USERS, INCLUDING THOSE USING
SCREEN READER SOFTWARE.NEW ACCESSIBILITY FEATURES FOR FM DESKTOP
APPLICATIONS SUPPORTS JAWS ON WINDOWS AND VOICEOVER ON MAC OS X
QUALITY, PERFORMANCE AND STABILITY
GET THE BEST DEVELOPMENT EXPERIENCE AND DELIVER THE BEST USER EXPERIENCE
FOR YOUR USERS ADDRESSED OVER 2,000 REPORTED ISSUES INCREASED OVERALL
APPLICATION RUNTIME PERFORMANCE ON ALL PLATFORMS
FIND DEFINITION AND FIND REFERENCES
FIND ALL REFERENCES TO A SELECTED ITEM ACROSS YOUR ENTIRE PROJECT
FOR C++ ON WIN64, IOS AND ANDROID
CORE AND DATABASE FEATURES
CORE ENHANCEMENTS THROUGHOUT THE PRODUCT DATASNAP
PERFORMANCE AND UPDATED WIZARDS DATABASE AND FIREDAC
ENHANCEMENTS, FDMEMTABLE RTL REFACTORING AND
ENHANCEMENTS DATABASE EXPLORER FOR FIREDAC
APACHE
SUPPORT (WEBBROKER) DIRECTX 11 HEADERS
IREDAC
INFORMIX DRIVER UPDATES
APACHE C++ SUPPORT

BLAISE
BLAISE PASCAL
PASCAL MAGAZINE
MAGAZINE
D E L P H I, L A Z A R U S, O X Y G E N E, S M A R T, A N D P A S C A L R E L A T E D
L A N G U A G E S F O R A N D R O I D, I O S, M A C,
W I N D O W S & L I N U X

CONTENTS
Article overview

New: Delphi XE6

Interview with
Professor Dr.Wirth

PAGE 43

A story about Pascal


becomming famous
an interview about the
great manbehind Pascal
By Detlef Overbeek PAGE 35
Databases for XE6
By Cary Jensen
PAGE 59

Steps in MindScape AppView


Step-By-Step
Continuation
of the article
in last double
issue Nr31/32

2014 Tour

By Jeroen Pluimers PAGE 26


Updating DotTapper

Suite Rays components


By Rik Smit PAGE 14

DC/Baltimore
Chicago
Frankfurt
Amsterdam
London

Bob Swart
&
Cary Jensen

May 5-6
May 8-9
May26-27
June 12-13
June 18-19

Delphi
Developer Days

maXbox Starter 5

maXbox

By Jeremy North PAGE 53

Start with DLL


A Library for All

By Max Kleiner PAGE 5

Programming
Truth Table reduction
By David Dirkse
PAGE 46

COMPONENTS
DEVELOPERS

Components 4 Developers
By Fikret Hasovitch PAGE 65

Articles
maXbox Starter 5 Start with DLL A Library for All By Max Kleiner Page 5
Suite Rays components By Rik Smit Page 14
Interview with Pofessor Dr. Niklaus Wirth By Max Kleiner Page 26
Steps in MindScape AppView Step-By-Step By Jeroen Pluimers Page 26

New: Delphi XE 6 Page 43


Programming Truth Table reduction By David Dirkse Page 46
Databases for XE6 By Cary Jensen Page 59
Updating DotTapper By Jeremy North Page 53
Six new ready to use components! By Fikret Hasovitch Page 65

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Alexander Alexeev
alexander@blaisepascal.ru

Peter Bijlsma
peter.bijlsma@hcc-pgg.nl

Michal Van Canneyt


michael@freepascal.org

Marco Cant
marco.cantu@gmail.com

David Dirkse
David@davdata.nl

Daniele Teti
d.teti@bittime.it

Bruno Fierens
bruno.fierens@tmssoftware.com

Primo Gabrijeli
primoz@gabrijelcic.org

Fikret Hasovic
fhasovic@yahoo.com

Cary Jensen
cary@jensendatasystems.com

Wagner R. Landgraf

Sergey Lyubeznyy
slyubez@mail.ru

Kim Madsen
kbm@components4developers.com

Felipe Monteiro de Cavalho


felipemonteiro.carvalho@gmail.

Mattias Gaertner
nc-gaertnma@netcologne.de

Jeremy North
jeremy.north@gmail.com

Tim Opsteeg

Detlef Overbeek
editor@blaisepascal.eu

Howard Page Clark


hdpc@talktalk.net

Jeroen Pluimers
jeroen@pluimers.com

Rik Smit
rik.smit@hccnet.nl

Bob Swart
Bob@eBob42.com

Authors
A
B
C
D
F
G
H
J
L
K
M
N
O
P
S

Alexander Alexeev
Peter Bijlsma,
Michal Van Canneyt, Marco Cant,
David Dirkse, Daniele Teti
Bruno Fierens
Primo Gabrijeli,
Fikret Hasovic
Cary Jensen
Wagner R. Landgraf, Sergey Lyubeznyy
Max Kleiner
Kim Madsen, Felipe Monteiro de Cavalho
Jeremy North,
Tim Opsteeg, Inoussa Ouedraogo
Howard Page-Clark, Jeroen Pluimers
Rik Smit, Bob Swart,

Advertisers
Barnsten
BetterOffice
Components 4 Developers
Delphi Developer days
Fastreport
Raize Software
Pascon
Smart Mobile Studio

Pag
Page
Page
Page
Page
Page
Page
Page

45
13/52
68
34/64
4
22
2
23

Editor - in - chief
Detlef D. Overbeek, Netherlands Tel.: +31 (0)30 890.66.44 / Mobile: +31 (0)6 21.23.62.68
News and Press Releases email only to editor@blaisepascal.eu
Editors
Peter Bijlsma, W. (Wim) van Ingen Schenau, Rik Smit,
Correctors
Howard Page-Clark, James D. Duff
Trademarks
All trademarks used are acknowledged as the property of their respective owners.
Caveat Whilst we endeavour to ensure that what is published in the magazine is correct, we cannot accept responsibility for any errors or omissions.
If you notice something which may be incorrect, please contact the Editor and we will publish a correction where relevant.
Subscriptions ( 2013 prices )
1: Printed version: subscription 60.-- Incl. VAT 6 % (including code, programs and printed magazine,
6 issues per year excluding postage).
2: Electronic - non printed subscription 45.-- Incl. VAT 21%
(including code, programs and download magazine)
Subscriptions can be taken out online at www.blaisepascal.eu or by written order, or by sending an email to office@blaisepascal.eu
Subscriptions can start at any date. All issues published in the calendar year of the subscription will be sent as well.
Subscriptions run 365 days. Subscriptions will not be prolonged without notice. Receipt of payment will be sent by email.
Subscriptions can be paid by sending the payment to:
ABN AMRO Bank Account no. 44 19 60 863 or by credit card: Paypal
Name: Pro Pascal Foundation-Foundation for Supporting the Pascal Programming Language (Stichting Ondersteuning Programeertaal Pascal)
IBAN: NL82 ABNA 0441960863 BIC ABNANL2A VAT no.: 81 42 54 147 (Stichting Programmeertaal Pascal)
Subscription department Edelstenenbaan 21 / 3402 XA IJsselstein, The Netherlands / Tel.: + 31 (0) 30 890.66.44 / Mobile: + 31 (0) 6 21.23.62.68
office@blaisepascal.eu

Copyright notice
All material published in Blaise Pascal is copyright SOPP Stichting Ondersteuning Programeertaal Pascal unless otherwise noted and may
not be copied, distributed or republished without written permission. Authors agree that code associated with their articles will be made
available to subscribers after publication by placing it on the website of the PGG for download, and that articles and code will be placed on
distributable data storage media. Use of program listings by subscribers for research and study purposes is allowed, but not for commercial
purposes. Commercial use of program listings and code is prohibited without the written permission of the author.

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

maXbox

maXbox Starter 28
starter

maXbox

expert

Start with DLL


1.1 A Library for All
The purpose of writing programs is communication.
And communication needs structure. A DLL can help to
structure the system.
A DLL is not XML or UML those L stands for language.
A DLL is a library, short for Dynamic Link Library, a
library of executable functions or data that can be used
by a Windows or Linux application.
Typically, a DLL provides one or more particular functions
and a program accesses the functions by creating either
a static or dynamic link to the DLL.

A static link remains constant during program execution


while a dynamic link is created by the program as needed.
DLLs can also contain just data. DLL files usually end with
the extension *.dll, *.exe, drv, or *.fon.
This is how we declare a function we want to use from a
DLL:
Function OpenProcess2(dwDesiredAccess: DWORD;
bInheritHandle: BOOL; dwProcessId:DWORD):
THandle;
External 'OpenProcess@kernel32.dll stdcall';

Suppose you want to use the function OpenProcess of the


'kernel32.dll'.
All you have to do is to declare above statement and you
get access to the kernel!
With external you made these functions available to callers
external to the DLL, so we must export them or at least say
the function we use is from External. This means also to
use the modifier stdcall because this is a C convention.
The function name OpenProcess2 is different from the
original name OpenProcess! This is an alias to prevent
name conflicts or name it you like because you do have
conventions you are free to rename the function in your
script.
That's all for the meantime, now you can call the function:
ProcessHandle:=
OpenProcess2(PROCESS_QUERY_INFORMATION
or PROCESS_VM_READ, false, ProcessID);

And you get back the process handle like: > 904

PROCESS_VM_READ is required to read memory in a


process using. By the way the script you get all this
is:www.softwareschule.ch/examples/440_DLL_Tutor2.t
xt

With our DLL that just copied and pasted from the script
folder, we will use a next example to retrieve version
information. Until this call here some more topics.

Windows DLLs usually have no safety whatsoever.


The DLLs that interface with HW are kernel mode drivers
that can wreak havoc and gone. Extreme care has to be
used when passing parameters to the DLLs.
Usually you have an interface module that establishes
mapping between DLL and Pascal functions so there
should be a tested environment in your box.
The advantage of a DLL is:
For most applications, packages in an object oriented sense
provide greater flexibility and are easier to create than
DLLs. However, there are several situations where DLLs
would be better suited to your projects than packages:

Your code module will be called from


non-Pascal application.

You are extending the functionality of a Web server.

You are creating a code module to be used by thirdparty developers.

Your project is an OLE container.


I don't explain those points just for your insights. Let me
say a few words about building a DLL which is not theme
of this tutorial. When we update a DLL (change function's
implementation), we simply compile it, export some new
routines and ship the new version. All the applications
using this DLL will still work (unless, of course, you've
removed or ruined existing exported routines).
This solution does not support static binding. From a C or
C++ application, static binding is achieved by linking
import records (either import libraries or entries in the
IMPORTS section of the application's Module Definition
File) to the calling application. Using standard Delphi,
static binding is achieved using a declaration such as:
function xFoobox (param: Integer): Integer;
stdcall; external 'mytools.dll' name 'Foobox';

Writeln('Process Handle:'+intToStr(ProcessHandle));

A DLL can be used by several applications at the same


time. Some DLLs are provided with the Windows
operating system and available for any Win application.
Other DLLs are written for a particular application and are
loaded within the application.
Oh wait a minute, you can't call the function because there
is one parameter missing:

Therefore we use in maXbox also static binding but in the


runtime loading of the script engine.
You can use either c++ or Structured Exception Handling
in the DLL. For best results, exceptions should be caught
within the scope of the DLL throwing the exception. If the
calling application is built with Borland c++, Delphi or MS
c++, the exception can be caught in the application calling
ProcessHandle:=
the DLL. However, VB does not seem to have an exception
OpenProcess2(PROCESS_QUERY_INFORMATION
handling syntax. O.k. enough of technical grabbing let's
or PROCESS_VM_READ, false, ProcessID);
chose the second function called
The first is set of constants already declared, the second is
GetProcessMemoryInfo() to glue it with the first
just false but by the third you need the ProcessID to get the function, hope you remember, OpenProcess() together. In
corresponding handle, that's life.
the end we put those 2 DLL functions in our script
So you get the current ProcessId by simply call the function function!
GetCurrentProcessID
ProcessHandle:= OpenProcess2(PROCESS_QUERY_INFORMATION
or PROCESS_VM_READ, false, GetCurrentProcessID);

In Linux we say .so for shared objects


The const PROCESS_QUERY_INFORMATION retrieves
certain information about a process, such as its token, exit
code, and priority class and the other const

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

This as an overview:
We started with OpenProcess from kernel32.dll

COMPONENTS
DEVELOPERS

Raize Components Version 6


starter

expert

By Rik Smit

Delphi XE and later

Raize Components is a user interface design


system for Borland Delphi and Borland
C++Builder. At its center is a collection of more
than 125 general-purpose native VCL controls.
Built on a foundation of technology first created
more than eight years ago, these high-quality
components give developers unsurpassed power
and flexibility without sacrificing ease-of-use.
In addition to the core set of controls, Raize
Components includes more than 100 component
designers focused on simplifying user interface
development. Now more than ever, developers use
Raize Components to build sophisticated user
interfaces in less time with less effort.

Ive chosen for Delphi XE4, but you can also make
combinations of various different versions.
After the last ok everything goes automatically. When
Delphi is then started, youll see that the components are
loaded during start-up (Figure 2) and eventually youll find
them at the bottom part of the Component Palette (Figure
3). So everything is done for you. Because its rather
laborious to get this group on top of the Palette (if you
prefer that) Raize supplied a program that does this job for
you. Run it and youre done!.

Installation is very simple; after unzipping RC6.zip you


start RC6.exe. The installation procedure follows a number
of steps, one of them is the selection menu to select the
Delphi version for which you want the components to be
installed (Figure 1).

Figure 1: Make a selection for the Delphi version involved

Figure 3: The Component Palette with the 7


additional Raize component groups

In the Component Palette


shown in Figure 3 you see
that 7 Raize groups are
added: Raize Panels (17),
Raize Edits (25), Raize
Lists (19 of which 4 DB
related), Raize Buttons (16
of which 2 DB related),
Raize Display (27), Raize
Shell (11), and Raize
Widgets (16).
So all together more than
120 components: Too
many to mention them all,
so examine the screenshots
of the folded out groups in
Figure 4 to get an idea
what it is all about.

14

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

21

2.01
The license is now
free for students!
Smart Mobile Studio now offers a free educational licence for students in
school or university or who are members of an after-school coding club.

22
20
30

Nr 4
1 / 2013
2014 BLAISE PASCAL MAGAZINE
www.SmartMobileStudio.com
DEVELOPERS 4
COMPONENTS

Great news for SMART: Create your own controls


starter

expert

Smart versie 2.01


In the world of Delphi there are two archetypal
programmers: Those that stick to the high level
interface of Delphi, meaning that they only use premade controls and rarely go beneath the bonnet and
the second group which create components, packages
and love to fiddle around with low-level coding. This
type of stereotyping is something more or less unique to
RAD languages (which would include Delphi, Lazarus,
Visual Basic, Real Basic and languages that are design
based). In more mature languages like C++, Delphi
(yes Delphi is just as low level as the C++) or C# lowlevel work is almost unavoidable.
With Smart Mobile Studio we have tried to retain
much of the high level abstraction you would expect
from Delphi, but sadly the HTML5 platform is not as
feature rich as the windows API. So the system
demands that if you want something unique, you have
to create your own controls in order to stand out. If not,
you might as well go with the many template-based
app machines out there that produce programs that all
look and feel the same.

type
TW3HeaderControl = Class(TW3CustomControl)
private
FLabel:
TW3Label;
FBackBtn:
TW3ToolButton;
FNextBtn:
TW3ToolButton;
Protected
Resize;Override;
Procedure
protected
InitializeObject;override;
Procedure
FinalizeObject;override;
Procedure
StyleTagObject;override;
Procedure
End;

Under Delphi you would probably expect to see a


constructor and destructor in the above code, but under
OP4JS we try to synchronize the number of steps taken to
establish a control (i.e number of resize and position
operations). So to solve this we have introduced 3 new
methods: InitializeObject, FinalizeObject and StyleTagObject.
As the names imply you create any sub-controls and
initialize your variables in InitializeObject (just think of it as
your constructor), you destroy those instances in
FinalizeObject, and you apply any extra styling or property
alteration in the StyleTagObject method.
Clever styling
When a control is in the state of creation, it automatically
set its own style class (think html here) to the name of its
class. So in order to give our little control a nice look we
edit the default style sheet (this is automatically created
when you create a new application) and make it look like a
true iPhone header. The rule of thumb is: The name of the
CSS class always matches the name of the OP4JS control:
.TW3HeaderControl
background-image:-webkit-gradient(linear, left
top, left bottom,
from(#b2bbca),
color-stop(0.25, #a7b0c3),
color-stop(0.5, #909cb3),
color-stop(0.5, #8593ac),
color-stop(0.75, #7c8ba5),
to(#73839f));
border-top: 1px s
Adding behavior
If you dont know anything about CSS or HTML, dont
worry, you can always copy a style you like from the
default skin, and there are plenty of examples around the
Internet to learn from (or just get a good book, that would
save you a lot of time). OK now we need to add some code
to our unit to make it come alive:
Procedure TW3HeaderControl.InitializeObject;
Begin
inherited;
FLabel:=TW3Label.Create(self);
FLabel.BorderStyle:=bsDotted;
end;

The basics of a control


There are two types of controls you can create under
OP4JS: Graphical controls and ordinary parent/child
controls (like you are used to from Delphi). A graphical
control is an object that contains a HTML5 graphics context
and canvas, which means you have to draw it yourself.
This is good for things like games, charts or anything that
cant be represented using normal html.

Procedure TW3HeaderControl.FinalizeObject;
Begin
FLabel.free;
if assigned(FBackBtn) then FBackBtn.free;
if assigned(FNextBtn) then FNextBtn.free;
inherited;
end

The second type, which is the one 90% of all the standard
controls that ship with Smart Mobile Studio derive from, is
TW3CustomControl. So lets have a look at how setting up
a fancy iPhone header looks like:

Procedure TW3HeaderControl.StyleTagObject;
Begin
inherited StyleTagObject;
end;;

24

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Great news for SMART: Create your own controls


Procedure TW3HeaderControl.Resize;
var
wd,hd: Integer; mTemp: Integer;
dx:
Integer;
Begin
wd:=Width; hd:=Height;
mTemp:=wd; dx:=4;
dec(mTemp,4); //left margin
dec(mTemp,4); //Right margin
if assigned(FBackBtn)
and (FBackBtn.Visible) then
Begin
//space between "back" & label
dec(mTemp,FBackBtn.width);
dec(mTemp,2);
//offset the left edge of the label
inc(dx,FBackBtn.Width);
inc(dx,2);
// position the back-button
FBackBtn.Left:=4;
FBackBtn.Top:=4;
end;
if assigned(FNextBtn)and(FNextBtn.Visible)then
Begin
//space between label & "next" button
dec(mTemp,FNextBtn.width);
dec(mTemp,2);
FNextBtn.Left:=mTemp;
FNextBtn.Top:=4;
end;
FLabel.left:=dx;
FLabel.top:=4;
FLabel.Width:=mTemp;
FLabel.Height:=Height-8;
end;

Why all that code? First of all because a typical iPhone


header have 3 parts: A back button, a next button and some
text in the middle. The above code checks to see if you
actually have created a back or next button and shrinks the
text area accordingly. Lets see how it looks so far:

That was easy enough


I have set the label to have a dotted frame just to make it
easier to work with, we will of-course remove the frame all
together later. But now, lets add some more methods to
the class interface. We want to expose the label object to
give the user access to its full capabilities (caption, font,
background, orientation and all the rest), and we also want
both back and next buttons. But, we want to keep resources
to a bare minimum, so we will use the old need trick and
only create the buttons when asked for. So the buttons will
only be created when you access them:

And the implementation for our


new methods are (this is just a quick example):
Procedure TW3HeaderControl.NeedBackButton;
// Create object on the fly if required
Begin
if not assigned(FBackBtn) then
Begin
BeginUpdate;
FBackBtn:= TW3ToolButton.Create(Self);
SetReSized; EndUpdate;
end;
end;
Procedure TW3HeaderControl.NeedNextButton;
Begin
// Create object on the fly if required
if not assigned(FNextbtn) then
Begin
BeginUpdate;
FNextbtn:= TW3ToolButton.Create(Self);
SetReSized; EndUpdate;
end;
end;
functionTW3HeaderControl.getBackButton:TW3ToolButton;
Begin
NeedBackButton; result:=FBackBtn;
end;
function
TW3HeaderControl.getNextButton:TW3ToolButton;
Begin
NeedNextButton; result:=FNextBtn;
end;
procedure TW3HeaderControl.ReleaseButtons;
Begin
if assigned(FBackBtn) then
Begin
FBackBtn.free;
FBackBtn:=NIL;
end;
if assigned(FBackBtn) then
Begin
FNextBtn.free;
FNextBtn:=NIL;
end;
end;

The final product


To use our new control, all we have to write (in our Forms
InitializeObject for instance) is something like:
FMyCoolHeader:=TW3HeaderControl.Create(self);
FMyCoolHeader.BackButton.Caption:='Back';
FMyCoolHeader.BackButton.onClick:=
HandleBackButtonClicked;
FMyCoolHeader.Title.Caption:='My cool header!';

And voila we have a nifty iPhone header that looks and


feels like the real thing.

TW3HeaderControl = Class(TW3CustomControl)
private
FLabel:
TW3Label;
FBackBtn:
TW3ToolButton;
FNextBtn:
TW3ToolButton;
procedure
ReleaseButtons;
Procedure
NeedBackButton;
Procedure
NeedNextButton;
function
getBackButton:TW3ToolButton;
function
getNextButton:TW3ToolButton;
Protected
Procedure
Resize;Override;
protected
Procedure
InitializeObject;override;
Procedure
FinalizeObject;override;
Procedure
StyleTagObject;override;
public
Property
BackButton:TW3ToolButton read
getBackButton;
Property
NextButton:TW3ToolButton read
getNextButton;
property
Title:TW3Label read FLabel;
Property
Options:TW3HeaderButtonOptions
read FOptions write setOptions;
End;

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

25

Steps in MindScape AppView Step - By - Step


Continuation of the article in last double issue Nr 31/32
starter

By Jeroen Pluimers

expert

Step 10: Binding Actions to the View Model.


One of the Delphi features I really like are actions
implemented in TAction and the TActionManager or
TActionList. Note I referred to the VCL documentation of
these, but FireMonkey includes implementations of
TAction and TActionList and as well.
Currently, there is no TActionManager in FireMonkey,
though I hope on the future someone will develop one.
UI modifications part 1: the visual part
Let's start with the UI: it will be a whole bunch of
controls, so here is a screenshot

function TAppViewModel.GetCanMultiplyCountBy2():
Boolean;
begin
Result := (Count * 2 <= MaximumCount)
and (Count * 2 >= MinimumCount);
end;
procedure TAppViewModel.IncrementCountBy2();
begin
if not CanIncrementCountBy2 then
raise EInvalidOperation.Create(
'not CanIncrementCountBy2');
Count := Count + 2;
end;
procedure TAppViewModel.MultiplyCountBy2();
begin
if not CanMultiplyCountBy2 then
raise EInvalidOperation.Create(
'not CanMultiplyCountBy2');
Count := Count * 2;
end

Modify the SetCount method so it notifies about the.


NotifyOfPropertyChange('CanIncrementCountBy2');
NotifyOfPropertyChange('CanMultiplyCountBy2');

and the list of components:


ActionManager1: TActionManager;
IncrementByTwo: TAction;
MultipyByTwo: TAction;
Button1: TButton;
Button2: TButton;
ActionToolBar1: TActionToolBar;
ActionMainMenuBar1: TActionMainMenuBar;

UI modifications part 2: the code

Here we will solve the difference in naming of the actions


in the View Model (IncrementCountBy2 and
MultiplyCountBy2) the name of the actions in the View
(IncrementByTwo and MultipyByTwo).
The text you can paste to get these components on your form Of course you could rename either two. But in practice you
is at https://gist.github.com/jpluimers/8149358 will often come along a View or View Model that you
cannot modify in one way or the other (or both). And that's
but this is the summary:
why Caliburn allows for manual binding with either
attributes or with code. Let's do attributes first.
1. ActionManager has two actions, both
So add these attributes:
in the Count category:
Action MultipyByTwo has a Caption of *2
[Binding('OnExecute','{Binding IncrementCountBy2}')]
Action IncrementByTwo has a Caption of +2
[Binding('Enabled', '{Binding CanIncrementCountBy2}')]
2. Button1 is bound to action MultipyByTwo
IncrementByTwo: TAction;
3. Button2 is bound to action IncrementByTwo
[Binding('OnExecute', '{Binding MultiplyCountBy2}')]
[Binding('Enabled', '{Binding CanMultiplyCountBy2}')]
4. ActionToolBar1 binds to ActionToolBar1
MultipyByTwo: TAction;
and has buttons for both the individual actions
as well as the Count category.
If you compile it as is, you get the dreaded W1025
5. ActionMainMenuBar1 binds to ActionToolBar1
compiler warning:
has menu items for the individual actions.
[dcc32 Warning] AppViewForm.pas(24):
W1025 Unsupported language feature: 'custom
I also fixed the tab-order, as I'm a keyboard guy.
attribute'
Model additions

This is one of the Delphi compiler design issues I do not


agree with: when you use an attribute that is not in scope,
the compiler generates a warning, but not an error. I'm not
sure if custom attribute is related to the
TCustomAttribute class.

Add these public properties:


property CanIncrementCountBy2:
Boolean read GetCanIncrementCountBy2;
property CanMultiplyCountBy2:
Boolean read GetCanMultiplyCountBy2;

In order to use these attributes, you need to add the unit


DSharp.PresentationModel to the uses clauses in the
interface. BTW: Don't forget to make sure that
DSharp.Bindings.VCLControls is the last unit in the
function TAppViewModel.GetCanIncrementCountBy2(): uses list.
Boolean;

Add these methods (the first two are strict protected, the final
two public; in my book all methods are virtual):

begin
Result := Count + 1 < MaximumCount;
end;

26

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Interview With Professor Dr Wirth

Niklaus Wirth is the father of Pascal and


continues to introduce creative innovations in the
world of computer programming. He was born on
February 1934 in Winterthur, Switzerland.
He received an electronics engineering degree
from the Swiss Federal Institute of Technology
(ETH) in Zurich in 1959, an M.Sc. from Laval
University, Canada, in 1960, and a Ph.D. from the
University of California at Berkeley in 1963.
He was Assistant Professor of Computer
Science at Stanford University (1963 - 1967), and
then at the University of Zurich. In 1968 he
became Professor of Informatics at ETH Zurich.
He spent two sabbatical years at the Xerox
PARC in California. Since April 1999 he has been
retired; however he has continued to develop the
latest incarnation of Pascal, named Oberon.
He received the Turing Prize in 1984, and
subsequently five honorary doctorates, and has
written numerous important books.
Niklaus Wirth never designed a computer
language for its own sake. Rather he developed a
new design to meet a practical need for which
there was no current solution. Modula and Oberon
were by-products of the designs of the
workstations Lilith (1979) and Ceres (1986). As a
teacher he was able to make the language as
simple as possible.
He concentrated on the essentials of
programming and not on the details of the
language and notation. "Good enough software"
as introduced by a large software development
company is seldom good enough. It is sad that in
modern times developers are rarely proud of their
work.
When software is developed for purely
commercial reasons its meaning resides largely in
its potential for revenue generation (or cost
minimization); and remuneration becomes
the principal motivation for writing
good software. The satisfactions of
elegance, creativity, didactic
potential, of crafting something
beautiful are lost.

Neither the police nor the University in Zurich would


release contact details, and so Max came up with a name
which he knew from earlier days Mr Cuno Pfister, a
former student of Professor Wirth who was involved with
Oberon and might be able to help usAnd he was able to
help. We found his address and got the opportunity to
make contact with the Professor and ask him for an
interview. Such a great opportunity to meet one of the most
important people for the development of software during
the 20th century.
Professor Wirth simply answered Yes!! and that's
how the event started: I began to consider what gift I could
take and found out that he would celebrate his 80th
birthday soon.
It would become quite an experience: I found a handbookbinder who could create a number of books out of
thirty issues of Blaise Pascal Magazine. I was not really
sure whether he would appreciate that, but something
more interesting I think would be hard to find - in my
mind - and so I organized its making.
We finally agreed to to have an interview and after
that of course a dinner at a very good restaurant.
We had to overcome some trouble in the waiting area
where there was a lot of noise, so sometimes we missed
some of the conversation and understanding because of the
noise.
Happily the questions were written down by Max and
in that way we were able to restore the event. After the
interview we had a gorgeous dinner and talked about
anything but Pascal. Max showed us the
university where professor Wirth started and we took in
much of the beauty of Zurich.
We photographed some of Computers he worked
with: including one that on account of its excessive weight
had been moved to more secure foundations in the
basement. That's where it all started.
After running through the University running because of
its vastness we went to the tower and we were taken up
50 floors to the topmost storey overlooking the city, where
the Restaurant was located.

The journey to Zurich


In September last year there was
conference in Cologne (Kln) Germany - where I met Max Kleiner.
Max lives in Switzerland. He is the
originator of maXbox, and a Pascal
addict. I asked him if I might be able
to meet Niklaus Wirth, and so the
idea for an interview was born.

35

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Interview With Professor Dr Wirth (continuation 1)

The restaurant called Clouds is at the 52 Floor

Prime Tower Zurich


Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

29

Interview With Professor Dr Wirth (continuation 2)


The view from inside the Clouds

30

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

What's New in RAD Studio XE6


Key New Features / Benefits
Application Tethering Components
Extend your existing Windows applications to mobile without having to port your
whole Windows application.
Pick the features that make sense on mobile and easily interact with
your existing Windows applications.
Connect your desktop (VCL and FMX) applications and mobile apps
Create mobile companion apps for your VCL applications
Works via Wi-Fi and on your local network. Future versions will support Bluetooth.
Taskbar component
Component for presenting previews of multiple windows
that are selectable in your app with button controls within the previews
Automatic or custom previews
Show progress in the taskbar button for your application
Overlay icons on taskbar buttons
Cloud Service (BaaS) integration with components for Kinvey and Parse
Integrate with leading Backend as a Service providers to add functionality
and platform services to your mobile applications.
You get easy access to common services in the cloud without having
to build or maintain the backend services yourself.
Use push notifications to engage your users on any device or platform
Access data and object storage in the cloud
User authentication
Builds on the REST client support introduced in XE5
Supports the three most popular BaaS providers Kinvey and
Parse with a common API component set
New VCL Styles
Give your applications an updated Windows or custom look
Includes a Windows tablet style
Supports Windows 7 and Windows 8
Fully style your applications including menus and borders
VCL sensor components
Sensors are everywhere, even for Windows users with new
Windows tablets like the Surface Pro.
Now your Delphi apps can add location, movement and other features.
Access device sensors from VCL apps running on Windows tablets
Accelerometer, GPS and gyroscope functionality

http://www.barnsten.com/
Or call: +31 (0)23 542 22 27
Nr 1 . 2014 BLAISE PASCAL MAGAZINE

43

What's New in RAD Studio XE6


Key New Features / Benefits

In-app purchase and in-app advertising


Mobile apps are a revenue generating opportunity for application developers.
Now you can monetize your mobile apps by integrating in-app purchase
functionality and advertising.
Sell content, functionality, services and subscriptions on iOS and Android
Supports the top ad networks (Google AdMob and Apple iAd)
Create apps for Google Glass
Multi-device application development with Delphi now extends beyond PCs,
tablets and smartphones to wearables. Create Android apps that run on
Google Glass. New custom style with Google Glass optimized look and resolution
Google Glass device designer template
Accessibility
Make your applications easier to use for more users,
including those using screen reader software.
New accessibility features for FM desktop applications
Supports JAWS on Windows and VoiceOver on Mac OS X
Quality, performance and stability
Get the best development experience and deliver
the best user experience for your users. Addressed over 2,000 reported issues
Increased overall application runtime performance on all platforms
Build Android apps with C++
Adds Android as a target platform for your apps in addition to Windows,
Mac OS X and iOS. Create apps for Android and iOS with a single C++ codebase
Run apps in the emulator and on ARM based Android devices
Supports multiple versions of Android including 4.4 KitKat
C++ Package Support for 64-bit Windows
Now you can fully port your 32-bit apps including packages to 64-bit
Put components into a shared library (DLL)
Find definition and find references
Find all references to a selected item across your entire project
For C++ on Win64, iOS and Android
Core and database features
Core enhancements throughout the product
Database and FireDAC enhancements, FDMemTable
Database Explorer for FireDAC
DirectX 11 headers. Apache C++ support
DataSnap performance and updated wizards
RTL refactoring and enhancements
Apache support (WebBroker)
FireDAC Informix driver updates

http://www.barnsten.com/
Or call: +31 (0)23 542 22 27

What can you do with RAD Studio XE6?


Develop apps for Windows, Mac,
iOS and Android using the tools
and language you know and trust.

Connect with popular cloud services


with REST as well as BaaS providers
for push notifications, authentication,
storage and more!

Push the envelope of performance


with 64-bit Windows to take
advantage of the latest hardware
and more memory.

Bind any UI control to other objects


or datasets.
With LiveBindings, every component
is data aware.

Get FireDAC high performance


enterprise database connectivity
and make database
app development fun again.

Develop multi-tier, enterprise


applications with DataSnap, an
integrated architecture spanning from
database servers to application and
data middleware, to client devices.

Join us and see all new great XE6 functionality


during the Developer Direct LIVE! Events.
Where and when:

May 8, 2014 Antwerpen.


If this is the pdf version please click here for the agenda and to register for this event

May 13, 2014 Utrecht.


If this is the pdf version please click here for the agenda and to register for this event

Be one of the first and get your XE6 license now!


In addition you will get a FREE Bonus pack including:
TMS modern Windows UI Pack
VCL Premium Style Pack
FireMonkey Preimium Style Pack
Order online or contact us for the best advise.

http://www.barnsten.com/
Or call: +31 (0)23 542 22 27

Programming Truth Table reduction By David Dirkse


starter

The proof follows from the table:

expert

Introduction
Boolean algebra is a kind of algebra that is used in the
design of digital circuits. Also it is of help in programs as
search engines and logic in general. Boolean algebra is
a numeric approach of proposition logic.
There are similarities with set theory.
Boolean algebra was invented by the British
mathematician George Boole (1815 - 1864).
This article describes how my program Logic10 reduces
truth tables by using the rules of Boolean algebra.

Variables and operators


As any algebra, there are variables, operators and
arithmetic rules.
A variable is denoted by a single character, like A , B, .....
A variable is a situation or proposition and possible values
are only "true" or "false". Example: A = "the door is open".
This is true or not, the door cannot be ajar.
For the purpose of calculations, "false" is given the
value 0 and "true" has value 1.
So, we find ourselves in the binary number system.
There are three basic logical operations: AND , OR,
complement.
The AND operator is the dot ( . ) ,
for OR it is the plus ( + )
The . between variables may be omitted:
A.B = AB
A.B = 1 if A=1 and B=1
A+B = 1 if A=1 or B=1 (or both A,B are
1)
In the case of switches, AND is serial , OR is parallel
connection.
Similar to negative numbers, there is a logical negation
called complement.
The complement is normally denoted by a horizontal bar
on top of the variable. Because this is hard to edit on a
computer screen, here we use a / before the variable that is
complemented. So /0 = 1 , /1 = 0.
Laws
For AND , OR operations, the commutative law applies:
AB = BA
A+B = B+A
also the associative law applies:
A(BC) = (AB)C
A+(B+C) =(A+B) + C

A
0
1
0
1

The proof if this laws is simple: let the variables take all
possible values and compare the results.
Reduction rules are:
A + /A = 1
A./A = 0
AA = A
A+A = A
A + AB = A
(absorbtion law)
AB + A/B = A
proof:
AB + A/B = A(B + /B) = A.1 = A

COMPONENTS
DEVELOPERS

B
0
0
1
1

/(AB)
1
1
1
0

/A + /B
1
1
1
0

/(A + B)
1
0
0
0

/A. /B
1
0
0
0

Using above rules all possible formula's may be reduced to


their most simple form. But programming the laws of
De Morgan is not simple, as this example illustrates:
/AP + /BP + /CP + ABC = P(/A + /B + /C) +
ABC = P./(ABC) + ABC = P + ABC
Another difficult case is this:
AB + /BC + AC = AB + /BC, the term AC is
redundant proof:
AC = ABC + A/BC, so
AB + /BC + AC = AB + ABC + /BC + A/BC = AB +
/BC
In 1991 I wrote a program to reduce Boolean algebra
formula's but I did not use the laws of De Morgan. So, not
all formula's were reduced to the limit. But end 2013 I
invented a new rule which obsoletes De Morgan. This is
what happened: When reducing formula's like AB + /BC
sometimes a new term AC showed up.
This is not wrong, but AC is redundant, see before.
Writing newer versions of my old logic program, I included
lengthy procedures to detect terms like AC and eliminate
them. Also, I included procedures to write /A + /B + /C as
/(ABC) and more complex data structures had to be added
as well. But still there remained leaks in the reduction.
Than I decided not to search for AC in case of AB + /BC
but to add AC .
AC I call a virtual term. AB , /BC I call the parents of AC.
A virtual term is called VT hereafter.
De trick is, that AC is temporarily added to the reduction
proces where it may

There are two distributive laws:


1. A(B+C) = AB + AC
2. A+BC = (A+B)(A+C)

46

A + /AB = A + B
proof using distributive law 2
A + /AB = (A+/A)(A+B) = 1.(A+B) = A+B
Special are the laws of De Morgan:
/(AB) = /A + /B
/(A + B) = /A. /B

reduce other terms of the truth table


be reduced itself
generate new VT's from other truth table terms

The result is amazing. Simple data structures and only one


reduction procedure remain and all known problems are
solved.
Virtual terms at work
VT's are printed fat.
The new law is : AB + /BC ---> AC
In words: if two terms have one variable complemented
(such as B , /B) , than a new term may be added that
contains all other factors of the terms.
Example:
AB/CD + CE/F ---> ABE/F

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Programming Truth Table reduction (Continuation 5 - end)

Below, a virtual term is made:

Control:
All input and output data may be saved, loaded or printed.
The Logic10 (Delphi-7) project
There are a form and five units:
- unit1 : event procedures, simple editor, load, save and print
procedures.
- xlate unit : procedures for formula translation and truth table
generation
- logic unit : data and procedures for truth table reduction
- debug unit : originally for testing purposes, later for information
about the translation and reduction.
- help unit : In-Line help information
To keep control over the step-by-step execution, two variables were added:
var continueflag : boolean;
DBwait : boolean;
........ {key event}
if key = #27 then continueflag := false;

#27 is the ESCAPE key code, it ends the translation or scan.


The continueflag is examined at several places in the code.
DBwait controls the pause
.......{key event}
if key = #32 then dbwait := false;

#32 is the SPACE key code, which advances the translation


or scan to the next step.
The program is paused by a call to DBpause.
procedure DBpause;
begin
if continueflag then
begin
DBwait := true;
while DBwait and continueflag do
application.ProcessMessages;
end
else DBwait := false;
end;

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

Reliability
How can we be sure that the output is reliable?
That not too much information was removed from
the truth table?
Logic10 offers this certainty. After the scans, a
comparison is made between the original formula
and the reduced truth table for all values of the
variables. If results are identical, the final
message is preceded by OK : followed by the
elapsed time.
This concludes the logic10 description.
For details, please refer to the source code.
And in case of commercial use, do not forget a
donation. Contact me at www.davdata.nl

COMPONENTS
DEVELOPERS

51

44

COMPONENTS
DEVELOPERS

Nr 1 / 2014 BLAISE PASCAL MAGAZINE

Updating Dot Tapper for XE5 and Android By Jeremy North


starter

expert

In this article we continue to enhance the Dot Tapper


application created last time by upgrading it to compile
under Delphi XE5 (for iOS) and also add Android
support.
Updating to Delphi XE5
Delphi XE5 introduced large changes to FireMonkey to
accommodate supporting Android. Numerous platform
specific classes and units were introduced but once
again a large number of changes were also made to
existing features.

New FMX.Graphics unit


A new unit was introduced FMX.Graphics, which means if
you tried to compile the previous Delphi XE4 version of the
application code in XE5 you would have got a compile
error. Thankfully, the changes required were only minimal.
NOTE: Delphi XE5 includes 32 units that didn't exist in
Delphi XE4. This article isn't about the general changes
between Delphi XE4 and Delphi XE5 releases and only
discusses changes between versions relating to the
application created.
GPU Canvas
New in Delphi XE5 is a deprecated message when
disabling the GPU Canvas which is used in the application.
When the GPU canvas is disabled under iOS 7 some really
odd drawing occurs when the keyboard is visible. The
downside of this is the dots look like they are drawn on a
VGA monitor.
Under iOS 7, the non GPU canvas display black artifacts
when buttons are pressed, the dots animation from black to
red doesn't work and the dot is half black and half red.
The cursor doesn't line up with the edit control.

you would have seen a large occurrence of the object


TSubImage in the style.
The TSubImage object was used to render platform specific
backgrounds and images from a common PNG image.
TSubImage was never available on the component palette
which has been identified as a bug in QualityCentral and
still unresolved however that isn't important now since it
has been deprecated.
TSubImage is backwards compatible with older Delphi
versions (back to XE3 where it was introduced) so older
styles using it will still work.
None of the custom styles in the application us TSubImage
so the deprecation of TSubImage is not an issue for this
application.
TStyleObject (TSubImage successor)
The TStyleObject is actually a welcome addition to the
FireMonkey styling system. It helps reduce the number of
objects required to form many common features (selected
text appearance, triggered animations) contained within a
style.
The new FMX.Styles.Objects unit is where TStyleObject and
a myriad of descendants can be found. If you do a lot of
custom styling, I recommend you spend some time looking
over the changes introduced by the new classes in this unit.
Mobile Preview style - Update 2 only
The recently released Update 2 for Rad Studio XE5
introduced support for C++ iOS applications. For many
years Embarcadero was telling us it wasn't able to release
new features in an update, and they have finally done it.
Well done Embarcadero, there should be lots more
thinking like this.

TSubImage deprecated
If you have customised a lot of styles in your application

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

53

Introduction to Database Development Part 14:

Named FireDAC Connections


starter

By Cary Jensen

expert

In the previous article in this series I discussed creating


FireDAC connections using the FDConnection
component. Connections created using the techniques
I described in that article are referred to as temporary
connections. In all, FireDAC supports three distinct types
of connections. These are:

Temporary connections

Private connections

Persistent connections
Which type of connection you employ determines how the
connection can be used and the features it offers. For
example, the temporary connections that I described in the
preceding article are referred to as unnamed connections.
These connection definitions cannot be shared, and they
cannot be pooled. They are, however, very easy to define at
either runtime or design time, and do not rely on an
external connection definition file.
Persistent connections can be pooled and the
connection definition can be shared by two or more
applications. Private connections can also be pooled.
Unlike persistent connections, however, they can only be
defined at runtime, and cannot be shared between
applications. On the other hand, private connections can be
shared by two or more threads within a single applications
(which is one situation where a private connection's
support for connection pooling can come in handy).
In this article I am going to show you how to create
persistent and private connections. These connections are
named connection, so let me begin by showing you how to
create named connections.

separately for every application. Most database developers


have one, or just a few, databases that they need to use across
many applications. For those situations, you can save time by
creating a named connection. This will allow you to easily
add new connections to your future applications with a
minimum of configuration.
Most developers use name connections to create persistent
connections, and these connection are those whose
parameters are stored in a connection definition file. Delphi
provides two GUI (graphical user interface) tools for
manipulating connection definition files: the FireDAC
Explorer and the Database Explorer. The following sections
show you how to create a named connection using each of
these tools.Creating Named Connections Using the FireDAC
Explorer
Creating Named Connections
Using the FireDAC Explorer
How you access the FireDAC Explorer depends on which
version of Delphi you are using. In some versions of Delphi
you can access the FireDAC Explorer from Delphi's menus.
In the most recent versions of Delphi, the FireDAC
Explorer can be accessed from the Tools menu by selecting
Tools | FireDAC Explorer.

The FireDAC Explorer is named FDExplorer.exe, and it is


located in Delphi's bin directory (which is C:\Program
Files (x86)\Embarcadero\Studio\14.0\Bin\ by
default in the most recent release).
As a result, if you are using an older version of Delphi and
Creating Named Connections
the FireDAC Explorer is not available from Delphi's menu
You use named connections to create private and persistent system, you can use the Tools | Configure Tools menu
item to add a Tools menu item for the FireDAC Explorer.
connections. While unnamed connections are convenient,
using them means that you must configure your connections The FireDAC Explorer is shown in Figure 1.

Figure 1. The FireDAC Explorer

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

59

SIX NEW READY TO USE COMPONENTS ! by Fikert Hasovic


from kbm for
Win32/64
OSX/IOS
Android
starter

expert

Our friends at components4developers are


very busy these days, trying to give us the
best possible experience on mobile platform.
There are 6 new components in kbmFMX.
TkbmFMXVerticalLayout
is a simple layout that stacks controls added vertically.
It autosizes in height to match the contained objects.
I will use it in samples bellow.
TkbmFMXImageControl is a bitmap viewer with
zoom/rotate/pan functionality built in.
In addition it allows people to define zones on top of the
image, that can be painted in various colors.
Let's put together some interface to demonstrate this
control. We can drop kbmFMXVerticalLayout on form,
some text control on top, and then put
kbmFMXImageControl, and three buttons, all on
kbmFMXVerticalLayout control. We need also one
ActionList component to add standard camera and gallery
functionalities. At the end, form will look like this:

function TfrmImage.AddZone:boolean;
var z:TkbmFMXImageZone;
begin
z:=kbmFMXImageControl1.NewZone(true);
if Assigned(z) then
begin
z.Kind:=TkbmFMXImageZoneKind.kbmizkCircle;
z.Fill.Color:=TAlphaColorRec.Green;
z.Fill.Kind:=TBrushKind.bkSolid;
z.Opacity:=0.5;
Result:=true;
end
else Result:=false;
end;
procedure TfrmImage.kbmFMXImageControl1ClickZone(
Sender: TObject;
const AZone: TkbmFMXImageZone);
begin
if AZone.Fill.Kind=TBrushKind.bkNone
then AZone.Fill.Kind:=TBrushKind.bkSolid
else AZone.Fill.Kind:=TBrushKind.bkNone;
AZone.Fill.Color:=TAlphaColorRec.Cadetblue;
end;

Now, we want to handle LongTap gesture, and we can do


that using following code:
procedure TfrmImage.kbmFMXImageControl1Gesture(
Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
begin
{$IFDEF ANDROID}
if EventInfo.GestureID=igiLongTap
then begin
if AddZone then Handled:= true;
end;
{$ENDIF}
end;

Figure 1: Then, we add some code to define zones.


The zones are "hotspots" which can be clicked etc.

Handling image rotation is very simple, just a single line

kbmFMXImageControl1.DisplayAngle := kbmFMXImageControl1.DisplayAngle-45;
Figure 2: Screenshot from actual device looks like above

Nr 1 . 2014 BLAISE PASCAL MAGAZINE

COMPONENTS
DEVELOPERS

65

kbmFMXFormLayout
with automatic support for scrolling active control so it will be visible when the keyboard is shown,
and to include a close keyboard button to close it again
kbmFMXPaintBox to do fingerpainting (signatures etc)
kbmFMXMemo
is an extension of the existing memo, bugfix
kbmFMXVerticalLayout
shows all its children vertically and autoresizes to fit all children and thus provide vertical scroll
if more children are available than can fit on to the screen
kbmFMXNumberInput
which is a numeric input control, that supports formatting like currency etc. while typing

kbmMW v4.50 just about being released!


kbmMemTable v. 7.50 available!
Supports Delphi/C++Builder/RAD Studio 2009 to XE5 (32bit, 64bit and OSX where applicable).
kbmMW for XE5 includes full support for Android and IOS (client and server).
kbmMW is the premier high performance, high
functionality multi tier product for serious
system development.
-

Native high performance 100% developer


defined application server with support for
loadbalancing and failover
Native high performance JSON and XML
(DOM and SAX) for easy integration with
external systems
Native support for RTTI assisted object
marshalling to and from XML/JSON, now also
with new fullfeatured XML schema
(XSD) import
High speed, unified database access
(35+ supported database APIs) with
connection pooling, metadata and
data caching on all tiers
Multi head access to the application server,
via AJAX, native binary, Publish/Subscribe,
SOAP, XML, RTMP from web browsers,
embedded devices, linked application
servers, PCs, mobile devices, Java systems
and many more clients

Supports Delphi/C++Builder/RAD Studio 2009 to


XE5 (32bit, 64bit and OSX where applicable).
kbmMW for XE5 includes full support for Android
and IOS (client and server).
kbmMemTable is the fastest and most feature rich
in memory table for Embarcadero products.
-

Easily supports large datasets


with millions of records
- Easy data streaming support
- Optional to use native SQL engine
- Supports nested transactions and undo
- Native and fast build in M/D,
aggregation /grouping,
range selection features
- Advanced indexing features for extreme
performance
Warning!

kbmMemTable and kbmMW


are highly addictive!
Once used, and you are hooked for life!

COMPONENTS
DEVELOPERS

EESB, SOA,MoM, EAI TOOLS FOR INTELLIGENT SOLUTIONS. kbmMW IS THE PREMIERE N-TIER PRODUCT FOR DELPHI / C++BUILDER
BDS DEVELOPMENT FRAMEWORK FOR WIN 32 / 64, .NET AND LINUX WITH CLIENTS RESIDING ON WIN32 / 64, .NET, LINUX, UNIX
MAINFRAMES, MINIS, EMBEDDED DEVICES, SMART PHONES AND TABLETS.

You might also like