Professional Documents
Culture Documents
L A Z A R U S,
O X Y G E N E,
S M A R T M O B I L E,
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
I
LA S
PA
L MAGAZINE
SCA
EDITORS CHOICE
1st PRIZE
AWARD WINNER
2015
FOR
Fast Reports
(HISTORY)
DRAG AND DROP EXPLAINED
LAZARUS
A R D U I N OFOR
: T HYOU
E V IFOR
SUIN
O P R O J EAND
C T - DELPHI
PART 2
C O L L E C T D A T A A N D W OBY
R KMICHAEL
W I T H I VAN
T I NCANNEYT
DELPHI
B Y B O IPACKAGE
AN MITOV
THE TMS LCL HW PACK FOR RASPBERRY PI OPEN-SOURCE
LOG, DEBUG AND AUDIT T
HE
KBMM
W WAY
BY
BRUNO
FIERENS
KIM MADSEN
TFRAMESTAND VERSION 1.1 RELEASED:B Y
WHAT'S
NEW!
BY ANDREA MAGNI
THE QUEENS PUZZLE PROGRAMMING DESCRIPTION
BY DAVID DIRKSE
INTERNET OF THINGS WITH ESP8266 AND VISUINO
BY BOIAN MITOV
E
S T U D
G
U
A
G
& L I N U X
I
E
O,
S
tmssoftware.com
productivity software buiding blocks
I
LA S
A G A Z I NE
CA L M
S
A
B
FOR
EDITORS CHOICE
1st PRIZE
AWARD WINNER
2015
Fast Reports
Reporting must be Fast!
Advertisers
Barnsten PAGE 30
COMPONENTS 4 DEVELOPERS PAGE 40
FASTREPORT PAGE 14
UPSCENE PAGE 36
MITOV SOFTWARE PAGE 28
Stephen Ball
http://delphiaball.co.uk
@DelphiABall
Dmitry Boyarintsev
dmitry.living @ gmail.com
Marco Cant
www.marcocantu.com
marco.cantu @ gmail.com
David Dirkse
www.davdata.nl
E-mail: David @ davdata.nl
Benno Evers
b.evers
@ everscustomtechnology.nl
Bruno Fierens
www.tmssoftware.com
bruno.fierens @ tmssoftware.com
Primo Gabrijeli
www.
primoz @ gabrijelcic.org
Fikret Hasovic
fhasovic @ yahoo.com
Cary Jensen
www.jensendatasystems.com
http://caryjensen.blogspot.nl
Max Kleiner
www.softwareschule.ch
max @ kleiner.com
John Kuiper
john_kuiper @ kpnmail.nl
Wagner R. Landgraf
wagner @ tmssoftware.com
Kim Madsen
www.component4developers
Andrea Magni
www.andreamagni.eu
andrea.magni@gmail.com
www.andreamagni.eu/wp
Boian Mitov
mitov@mitov.com
Andrea Raimondi
andrea.raimondi @ gmail.com
Rik Smit
rik @ blaisepascal.eu
Bob Swart
www.eBob42.com
Bob @ eBob42.com
B.J. Rao
contact@intricad.com
Daniele Teti
www.danieleteti.it
d.teti @ bittime.it
Anton Vogelaar
ajv @ vogelaar-electronics.com
Siegfried Zuhr
siegfried @ zuhr.nl
Andrea Raimondi ,
Stephen Ball, Peter Bijlsma, Dmitry Boyarintsev
Michal Van Canneyt, Marco Cant,
David Dirkse, Daniele Teti
Bruno Fierens
Primo Gabrijeli, Mattias Gaertner
Fikret Hasovic
Cary Jensen
Jeremy North
jeremy.north @ gmail.com
L
K
M
N
O
P
S
Z
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 80.-- Incl. VAT 6 % (including code, programs and printed magazine,
10 issues per year excluding postage).
2: Electronic - non printed subscription 50.-- 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.
DELPHI XE8
DELPHI
released February 14, 1995
The roots of Turbo Pascal v1.0 started in Denmark. The first step,
in 1981, was the Blue Label Software Pascal Compiler - BLS Pascal
Compiler v1.2, copyright 1981 by Poly-Data microcenter ApS,
Strandboulvarden 63, DK 2100 Copenhagen - written by Anders
Hejlsberg for the NASCOM kit computer.
Turbo Pascal
Developer(s) Anders Hejlsberg while
working at Borland
Operating system CP/M, CP/M-86, DOS,
Windows 3.x, Macintosh
Platform 8080/Z80, 8085, x86
Lisa - Pascal
Windows
Niklaus Wirth
Archimedes
Mathematician
Archimedes of Syracuse was an Ancient
Greek mathematician, physicist, engineer,
inventor, and astronomer.
He is regarded as one of the leading scientists
in classical antiquity. Wikipedia
Born: 287 - 212 BC, Syracuse, Italy
ISSUE 40
Page 9
WATER CLOCK - CHINA - BEGINNING OF TIME (BC 4000)
Some authors claim that water clocks appeared in China
as early as 4000 BC
expert
Delphi
INTRODUCTION
In a previous article, published within issue 4546, I have covered the basic functionalities of
TFrameStand, a FMX component to ease the use
of TFrame(s) in FMX applications. Since then I've
added a few significant features and this article
will cover them.
Before proceeding, I wanted to leave you a link (
https://youtu.be/Z6_ZvnCmFCw ) with the replay
of my TFrameStand session on CodeRage X, the
online Embarcadero conference held on October,
2015. It is a 50 minutes session covering all the
basic functionalities of the component. Another
resource (italian only) covering the aim and the
basics of TFrameStand is an audio interview I
released to delphipodcast.com (by Marco
Breveglieri) website (
http://www.delphipodcast.com/episode/6/massi
mizzare-user-experience-con-tframestand ).
CONCLUSION
This article illustrates the major improvements
introduced with v.1.1 of TFrameStand project.
Many developers are currently using this
component (mostly in mobile applications) and I
have received a good feedback both from the public
presentations (live and online) I did and via
personal e-mail messages.
I am also very happy some people are starting to
contribute (providing bugfixes), keep doing it! I
already have a couple of additions to implement in
the next version and a couple of new demos are
coming soon. So stay tuned and follow my blog (
tag TFrameStand:
http://www.andreamagni.eu/wp/tag/
tframestand/ ) for the latest news!
Andrea Magni
Web: www.andreamagni.eu
Blog: www.andreamagni.eu/wp
Twitter: @andreamagni82
STARTING WITH DRAG & DROP IN LAZARUS AND DELPHI PAGE 1/5
BY MICHAL VAN CANNEYT
starter
expert
ABSTRACT
In this article we show how to implement drag
and drop operations in your application.
INTRODUCTION
Drag and Drop is a common operation in a wellthought of GUI. It makes life for the user easier. It
is therefore good to have some knowledge on how
to implement drag and drop for simple (or less
simple) cases. In this article, we'll look at 2 types
of Drag&Drop:
1.Files dragged onto your application from a
file manager program (such as file explorer on
windows): The expectation of the user is then
that the application will open the files if it
supports the file format.
procedure TMainForm.HandleDrops(
var Msg: tagMSG; var Handled: Boolean)
begin
end;
It serves 2 purposes:
1. Retrieve the number of files that was
dropped (FileIndex equals $FFFFFFFF).
2. Retrieve the filenames of each of the files:
FileIndex (>0) indicates the index of the file.
The name of the file will be placed in a buffer,
whose size must be reported in cb.
Once the files were accepted, windows must be
notified that the drop is completed, this
happens with the DragFinish routine:
Procedure DragFinish(Drop: HDROP); stdcall;
STARTING WITH DRAG & DROP IN LAZARUS AND DELPHI PAGE 2/5
STARTING WITH DRAG & DROP IN LAZARUS AND DELPHI PAGE 3/5
The same code can be used for the LBRight
listbox. When the user relased the mouse at the
end of a drag&drop operation, the
OnDragDrop event is triggered. This event has
almost the same signature as the DragOver
event handler: it doesn't have the Accept
parameter. For the left listbox, this means the
eventhandler can be coded as follows:
OnStartDrag
procedure TMainForm.LBLeftDragDrop(
Sender, Source: TObject; X, Y: Integer);
begin
LBFrom:=(Source as TListBox);
LBTo:=(Sender as TListBox);
DragKind
This can be used to decide whether dragging the If (LBTo=LBFrom) then
MoveItemsToIndex(LBTo,LBTo.GetIndexAtXY(X,Y))
mouse starts a drag&drop operation or a
else
docking operation.
MoveItemsToListBox(LBTo,LBFrom,LBTo.GetIndexAtXY(X,Y));
11
STARTING WITH DRAG & DROP IN LAZARUS AND DELPHI PAGE 4/5
How can the Memo, Listview or ListBox
Drag&Drop operations are handled internally
controls on the secondary forms communicate
in the LCL and VCL using a TDragObject
class. The LCL and VCL differ somewhat in the
to the main form what items are dragged by the
descendent objects that they make available,
user ?
but other than that the mechanisms are
For this, a descendent of TDragObject is
identical.
created which can contain the items that will be
The VCL and LCL allow the programmer to
dragged. Since all controls show lists of strings,
create a custom instance of TDragObject
this object will have a property called Items of
when the drag operation is started: the
type TStrings:
OnStartDrag event handler can be used for
// For Delphi, the parent class is TDragControlObject
this. This instance is then used as the Source
TStringsDragObject = Class(TDragObjectEx)
parameter of the OnDragOver and
private
OnDragDrop events, instead of the control
FItems: Tstrings; // to keep the items in.
that started the drag operation.
procedure SetItems(const AValue: Tstrings);
Public
procedure
TMainForm.BListBoxWindowClick(Sender: TObject);
begin
With TListBoxForm.Create(Self) do
Show;
end;
NOTE that no reference to the created forms is
STARTING WITH DRAG & DROP IN LAZARUS AND DELPHI PAGE 5/5
procedure TListBoxForm.LBItemsStartDrag(Sender: TObject;
The biggest part of this routine has in fact
var DragObject: TDragObject);
Var SDO : TStringsDragObject; I : Integer;
begin
SDO:=TStringsDragObject.Create(LBItems);
DragObject:=SDO;
For I:=0 to LBItems.Count-1 do
If LBItems.Selected[i] then
SDO.Items.Add(LBItems.Items[i]);
end;
L:=LBMain.ItemAtPos(TPOint.Create(X,Y),true);
Conclusion
This article has shown that Drag&Drop is
really easy to implement be it from a file
manager to a program or inside a program:
It makes the operation of the program more
intuitive for the user, so adding Drag&Drop
should be considered by any Delphi or
Lazarus programmer, when it is appropriate
for the functioning of the program. One form
of drag&drop has not yet been discussed, and
that is dragging from one program to for
example the file manager. Exploring this is
left for a future contribution.
13
I
LA S
E
B
FOR
A G A Z I NE
CA L M
S
A
EDITORS CHOICE
1st PRIZE
AWARD WINNER
2015
Fast Reports
Reporting must be Fast!
FASTREPORT VCL:
FastReport VCL is an add-on component that
allows your application to generate reports
quickly and efficiently. FastReport provides all
the tools necessary for developing reports,
including a visual report designer, a reporting
core, and a preview window. Also available
Lazarus edition.
FASTREPORT FMX 2:
FastReport FMX 2 is a Multi-platform report
generator for Apple Mac OS X and Microsoft
Windows, compatible with Embarcadero RAD
Studio XE (FMX library), FireMonkey FM3.
FASTCUBE FMX, FASTCUBE VCL 2:
FastCube enables you to analyze data and to
build summary tables (data slices) as well as
create a variety of reports and graphs both
easily and instantly. It's a handy tool for the
efficient analysis of data arrays.
15
16
3.
4.
17
Click OK.
The ESP8266 project is
available on github here:
https://github.com/
esp8266/Arduino
I used the Staging
version, however, I had
some issues with it, and
had to manually get the
latest changes with GIT.
From the Menu select
|Tools|Board:......|Boards
Manager...|:
18
19
20
To make sure the Access Point will be on the 200.200.200.X subnet, we need to assign a fixed address.
Expand the Config sub property of the AccessPoint property. Set the value of the Enabled sub
property of the Config to True. Set the value of the IP sub property to 200.200.200.100:
Next we need to add a UDP socket for the communication. In the Object Inspector, click
on the
button next to the value of the Sockets sub property of the WiFi:
21
22
23
Connect with USB cable the first NodeMCU module (the one with the Thermometer connected to it)
to the computer. In the Arduino IDE from the menu select the type of the board that you have.
In my case this is NodeMCU 0.9 (ESP-12 Module):
24
Click on the
upload the
25
In the Object Inspector, expand the Config property, and set the value of the Enabled
sub property to True:
In the Object Inspector, set the value of the IP sub property to 200.200.200.200:
26
In the Elements editor select the Analog element, and then click on the
to add Analog element:
button:
27
28
Connect with USB cable the second NodeMCU module(the one with the Relay connected to it) to the
computer. If necessary in the Arduino IDE, select the module board type, and serial port, as you did for
the previous project.
Click on the
29
BELGIUM
Practicum: Delphi 10 Seattle with VCL and Mobile Development
1-Day Practicum
March 3, 2016 - Hotel Ter Elst Edegem (BE)
During this session you will start using Delphi 10 Seattle together with presentors Pawel
Glowacki and Danny Wind. Six differtent topics are covered this day.
Every topic will take about one hour. Pawel or Danny will explain more about the specific
topic and show you some code. After this you will get some time for practices using the
training materials written by Pawel and Danny.
Topics this day are:
how to build VCL Windows 10 applications
integrate with the new Windows 10 API
the use of the Parallel Programming Library for responsive applications
access to databases using FireDAC
create scalable and multitier solutions with DataSnap and REST
build and publish apps for the Google Play and iOS AppStore
During this Practicum you can bring your own laptop with Delphi 10 Seattle Enterprise
installed.The special price of this Practicum is 99,-- excl. VAT when you have bought or
will buy the 10 Seattle version via Barnsten. Also customers with an active Update
Subscription can join this practicum for 99,00 excl. VAT.
Otherwise the price is 295,00 excl. VAT.
NEDERLAND
TRAININGEN
Barnsten organiseert in samenwerking met Danny Wind van de Delphi Company diverse
Delphi en FireMonkey trainingen. Het doel van de trainingen is u, als Delphi ontwikkelaar,
snel productief te laten werken. Er zijn zowel Essentials als Advanced trainingen en
daarmee aanbod voor zowel de beginnende als de ervaren Delphi ontwikkelaar. Tijdens de
trainingen maakt u gebruik van uw eigen laptop met daarop Delphi 10 Seattle inclusief
InterBase XE7 genstalleerd (eventueel trial versie).
Datum
27-29 januari
17-18 februari
3 maart
11 maart
1.350,00
895,00
99,00
295,00
PAGE 1/5
expert
INTRODUCTION
At TMS software, we have recently published a first
version of the free and open-source TMS LCL HW
Pack for Raspberry Pi that you can download from:
http://www.tmssoftware.com/site/tmslclhwpack.as
p. The goal of the TMS LCL HW Pack for Raspberry
Pi is to make it very simple to do IO from Pascal
SDA
applications. One of the things that makes the
SCL
Raspberry Pi so versatile is its IO capabilities,
B1
B2
S
especially the Raspberry Pi 2 with a 40 pins header
that exposes generic GPIO pins, I2C, UART and SPI
Serialized data on the i2c 2-wire bus.
pins.
BN
tmssoftware.com
productivity software buiding blocks
Typical connection of
an SPI master to
SPI slaves
31
32
tmssoftware.com
productivity software buiding blocks
Issue Nr 1
102016
2015
BLAISE
BLAISE
PASCAL
PASCAL
MAGAZINE
MAGAZINE
Reading and writing in the FRAM (ferroelectric memory that can keep its memory
also when not powered) is simple with read &
write commands per byte:
function WriteByte(Adr: word; val: byte): boolean;
function ReadByte(Adr: word; var val: byte): boolean;
i2c 16x2 LCD display
+ 5 key keypad
i2c temperature
& barometric sensor
USING SPI
The SPI protocol is similar to i2c and is
encapsulated in the class TTMSLCLRaspiSPI. It
has a PortNum property to select the Raspberry Pi
which one of the two SPI ports to use. There is no
device address involved with SPI as a device on
SPI is accessed by driving the device selector pin
low for the device. This limits the number of
devices that can be directly connected to the
Raspberry Pi. The Raspberry Pi SPI clock speed is
configurable and maximum speed is 125MHz. The
TTMSLCLRaspiSPI class also has Open & Close
functions and a Connected property to read the
state. To transfer data via SPI to a device, there are
also the functions SetByteRegister and
GetByteRegister. In addition, there are functions:
ReadTransfer and WriteTransfer.
tmssoftware.com
productivity software buiding blocks
33
Schema:
tmssoftware.com
productivity software buiding blocks
CONCLUSION
With a few classes that enable you to directly access
hardware extensions for the Raspberry Pi, accessing
this hardware becomes dead-easy and you can fully
focus on being creative hooking up all kinds of
devices to the Raspberry Pi and automating things.
At this time we have classes for 9 hardware
extensions and we're busy developing more for other
extensions. As the TMS LCL HW Pack is an opensource project, we also invite anyone to participate
and share classes that you might have created that
wraps other hardware devices. Yes, it's 2016 and
programming in Pascal has never been more fun!
tmssoftware.com
productivity software buiding blocks
tmssoftware.com
productivity software buiding blocks
35
36
Issue Nr 1
102016
2015
BLAISE
BLAISE
PASCAL
PASCAL
MAGAZINE
MAGAZINE
expert
BY DAVID DIRKSE
A chessboard has 8 * 8 fields (colums * rows).
The board is painted in paintbox1 on form1. A field
counts 60 * 60 pixels. The queen is a bitmap of 50*50
pixels and is painted by the canvas.draw method.
........
end;
Variable playermode is true for allowing the player
to modify the board. If the program searches for a
solution, there are some states:
1. a new search starts
2. a search ends with no solution found
3. a search ends with a solution found
4. a search is temporarily pauzed to keep contact
with the Windows system
Therefore we introduce
type TsearchResult =
(srStart,srSolved,srNoSolution,srTimeout);
.
and the call:
procedure GoSolve(var sr : TsearchResult);
variabele sr defines the start condition and also
reports the exit condition. After a while, the GoSolve
procedure exits with sr=srTimeout just to allow the
processing of messages by the operating system. A
call with sr=srTimeout will resume the search
process. The main tasks during the search is
adding/removing queens to/from a field.
CODING THE BOARD
Qlist[1..8]
ADD / DELETE QUEENS
To add a queen in field at column i and row j:
procedure addqueen(i,j : byte);
begin
inc(Qcount);
board[i,j].Q := 1;
paintfield(i,j);
fixlines(i,j);
Qlist[Qcount].x := i;
Qlist[Qcount].y := j;
end;
37
BY DAVID DIRKSE
38
BY DAVID DIRKSE
39
Google's Project Loon balloons to cover Sri Lanka with internet access. The Project Loon balloons
are designed to fly through the stratosphere at around 20 km (12.4 mi) above the Earth's surface
Warning!
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.