Blaise Pascal Magazine 57: Livebindings in Delphi & C++ Builder VCL Applications
Blaise Pascal Magazine 57: Livebindings in Delphi & C++ Builder VCL Applications
Blaise Pascal Magazine 57: Livebindings in Delphi & C++ Builder VCL Applications
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
CONTENTS
ARTICLES:
LIVEBINDINGS IN DELPHI & C++ BUILDER PAGE 5
VCL APPLICATIONS
STEPHEN TELLS AS MUCH AS POSSIBLE ABOUT THE SUBJECTS
BY STEPHEN BALL
NEW VERSION OF FASTREPORT 6 PAGE 11
BY DEN ZUBOV
THE NEW VERSION WILL BE READY FOR THE FUTURE.
THE BASICS OF FUNCTION PLOTTING PAGE 17
BY DAVID DIRKSE
VERY HANDY TOOL TO CREATE
DATABASE WORKBENCH 5.2.2.130
THE NEWEST UPDATED VERSION PAGE 23
BY DETLEF OVERBEEK
WORK WITH CODE METRICS YOU SHOULD KNOW
MAXBOX 43 PAGE 30
THINGS ABOUT CODE YOU PROBABLY NEVER KNEW
BY MAX KLEINER
What is this?
ADVERTISERS
Barnsten page 4
Christmas offer page 16
Components4Developers page 40
Free Pascal and Lazarus Foundation page 22
Mitov Software page 29
Nexus page 39
Visuino page 15
Publisher: Foundation for Supporting the Pascal Programming Language
in collaboration with the Dutch Pascal User Group (Pascal Gebruikers Groep)
© Stichting Ondersteuning Programmeertaal Pascal
Max Kleiner
www.softwareschule.ch
max @ kleiner.com
Wim Van Ingen Schenau -Editor Peter van der Sman Rik Smit
wisone @ xs4all.nl sman @ prisman.nl rik @ blaisepascal.eu
www.romplesoft.de
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 [email protected]
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 [email protected]
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
[email protected]
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.
The Generators are sample data (many of which My favourite (from a business point) are the
are paired together to give values that make sense ContactXXXXX generators as these provide great
when seen together) e.g BitmapNames sample data for title, names and photos (with male
(ftString) has values Bitmap28, Bitmap40 etc and female names linked to gender relevant photos).
and the Bitmap (tfBitmap) has values that
show images with 24 and 40 in the middle. Once you have selected the Generator you want,
Further down you will also find Generators that enter a field name that will match the field you
have no data and just provide a fields type. want to use on your object. – Don’t worry if you
forget, you can always select the FieldDef later and
change the Name in the Object Inspector .
LINKING TO LIST
WITH TLINKLISTCONTROLTOFIELD;
The LinkListControlToField allows you to
link a specific field into a List. The example in the
video looks at using the TListView showing the
list of TFoo objects in the list represented by their
for Job Hunters
Name property.
ListLink :=TLinkListControlToField.Create(Self);
and Employers
ListLink.DataSource := PrototypeBindSource1; https://www.delphijobsboard.com
ListLink.FieldName := 'Name';
ListLink.Control := ListView1;
LINKING TO CONTROL
WITH TLINKCONTROLTOFIELD;
The TLinkControlToField allows you to link a
specific property to a control. It also
automatically helps control data input for
controls (e.g. it makes TEdit only accept Integers for
Integer fields).
LinkControl := TLinkControlToField.Create(Self);
LinkControl.DataSource := PrototypeBindSource1;
LinkControl.FieldName := 'Value';
LinkControl.Control := Edit1;
LinkControl.Track := True;
Finally…
About the author: Stephen Ball has lead
If you do you LiveBindings at runtime, then you development teams for over 15 within the UK,
may need to create tell the DataSource to refresh. Europe and beyond working with a range of
This is easily done by setting setting the blue chip companies including Hilton, American
PrototTypeBindSource.Active property to Express, Fitness First, Virgin Active;
False and back to True.
Stephen is a Chartered IT Professional and is
If you are interested there are also a number the Product Manager for the award winning
of videos available: InterBase and also a Product Evangelist for
https://delphiaball.co.uk/ RAD Studio, regularly speaking across EMEA.
LiveBinding to DataSets
LiveBinding to Objects
Creating LiveBindings via Code
Master Detail relationships (and objects as properties)
Advanced Master Detail Relationships
Mashing up Master Detail on different sources
Helpful classes for LiveBindings
The picture shows a comparison of the old (left Let’s look more closely at the new report object’s
side) versus the new logic (right side). Under the interactions.
old architecture, when a user made any change The diagram on the next page shows an
in the report designer, all that behavior was "Event sender" which receives a window message
managed by the report designer. And to make a and generates a similar message for the report
new interactive editor or introduce any new object. Both the Designer and Preview windows
object behavior meant that all the required hold a list of individual editors, and pass a
changes inside the report designer had to be reference to that list to the Sender object.
“hard-coded” . This severely limited the In our case the Sender is the window
extensibility of current versions of FastReport. (Designer or Preview) which generates the event.
The right hand side of the diagram shows an The report object receives an event detailing the
improved logic. The new architecture provides
for the report object itself to manage editing
available editors and the type of the Sender.
changes, and the report designer merely calls Based on these sets of passed parameters, the
report object events, displaying the report object can decide which editor to call and
outcome. how to interact with that editor.
Having called a particular editor and then This facilitates building complicated container
having subsequently facilitated the user to objects like Tables and Maps (these are newly
change the report object, the report object’s introduced objects in FastReport VCL).
Modify event is triggered and passed back to the
Sender. The Table object also has internal selectors for
This interactive scheme lets us build columns and rows, and all manipulations are
independent objects with customized behavior accomplished using child objects. A table object
which can call an appropriate editor whenever sorts all its children and can't accept, for
needed either in the Preview or in the Designer. example, an instance of another table class as
It is thus possible for a developer to build an column. In other words a table knows what
interactive inline editor for the report Preview, objects it can (or cannot) contain.
and edit objects in the Preview window without
needing the report Designer.
Fast Reports
Reporting must be Fast!
https://www.fast-report.com/nl/
Alexander Tzyganeko
DAVI
_Gam
DAVID DIRKSE COMPUTER MATH & GAMES IN PASCAL
/Com
p uterM
ath
FOR 75 EUROS + SHIPPING
irkse
u/DavidD
at cal.e
ales
pres laisepas
.b
INCLUDING:
www
• 53 projects and code fully explained.
HOWARD PAGE-CLARK
end;
end;
L I B R A R Y 2 0 1 6
TH & 3 4
1 2 5
MA
UTER PASCAL
6 10 12
7 8 9 11
M P 13 18 19
CO S IN 14 15 16 17 27
ME 20 25 26
GA 28
21
22 23 24
34
35 36 37
29 30 31+ 33
32
32 40 41 42
38 39 45+ 43
POCKET EDITION 46 47 48 49
44
Also printed in full color. 50 53
51 52 54+
A fully indexed PDF file is included. 55
Resize, rotate, compress digital images.
Design your own font, generate and reduce
Truth Tables from Boolean algebra.
And more important: understand how it all
works!
The book contains 87 chapters, 53 projects
with source code and compiled programs
(exe). The book is highly educational and
suitable for beginners as well as for WINDOWS 10
COMBINATION: 3 FOR 1
BOOK INCLUDING THE LIBRARY STICK EXCL. SHIPPING
INCLUDING 1YEAR DOWNLOAD FOR FREE
75€
http://www.blaisepascal.eu/david_dirkse/UK_Book_Department_DavData.html
16 Issue Nr 8 2016 BLAISE PASCAL MAGAZINE
SE
DIRK html
DAVID
mes.
HOWARD PAGE-CLARK
BY DAVID DIRKSE proce
var
dure
;
begin := 1 to
for i
9 do
begin
end ;
starter
end;
expert H&
R MAT
PUTE PASCAL
COM
ES IN
Delphi 7 and up to BERLIN GAM
DAVID
mes.
HOWARD PAGE-CLARK
THE BASICS OF FUNCTION PLOTTING PAGE 2/ 5 proce
var
dure
;
begin := 1 to
for i
begin
9 do
end ;
end;
H&
R MAT
PUTE PASCAL
COM
ES IN
GAM
Scalecodes are convenient because they may be Say we calculate f(x) for x values
incremented or decremented. 0, 0.5, 1, 1.5....
The scalecode defines the scale: First we position the (canvas) pen
on point(0,f(0)) then we draw a straight line to
scalecode scale (0.5 , f(0.5))
0 0.01 next we draw the line to (1,f(1)) etcetera.
1 0.02
2 0.05 However we deal with pixels, not coordinates.
3 0.1 A translation has to be made between coordinates
4 0.2 and pixels taking the scale and center values into
5 0.5 account.
6 1
Starting with X pixel 10, we calculate the
7 2
coordinate X value.
8 5 This X value is passed to a procedure which
9 10 calculates the function value.
DAVID
mes.
HOWARD PAGE-CLARK
THE BASICS OF FUNCTION PLOTTING PAGE 3 / 5 proce
var
dure
;
begin := 1 to
for i
begin
9 do
end ;
end;
H&
R MAT
PUTE PASCAL
COM
ES IN
FLOATING POINT EXCEPTIONS This code does the drawing: GAM
ASYMPTOTES
There is one other pitfall.
Imagine the function y = 1/x
This function calculates the value of the selected For x = -0.001 y = -1000.
formula For x = 0.001 y = 1000.
The vertical line x = 0 is called an
function getValue(x : single; var v : boolean) : single;
//calculate function value
asymptote.
var sqx : single; We do not want the drawing of asymptotes
begin as they do not represent valid function
result := 0; values.
try When asymptotes coincide with the
case formulaNr of
1 : result := 0.1*x*x-6; coordinate system raster, the valid flag will
2 : result := sqrt(64-sqr(x)); drop because we generate infinite floating
3 : begin point values.
sqx := x*x; The asymptote will not be drawn in this
result := sqx*(-0.01*sqx +0.5);
case.
end;
4 : result := 1/(x-2.001); The function y = 1/(x-0.01) however has
5 : result := 5/((x-4.001)*(x+3.999)); asymptote x = 0.01 and
end;//case for a horizontal scale of 1 (0.025 per pixel),
v := true; this happens:
except
x=0 ---> y = -100
v := false;
end; x = 0.025 ---> y = 66.67
end; Without extra checks and precautions,
the line from (0, -100) to (0.025, 66.67) is
drawn erroneously.
DAVID
mes.
HOWARD PAGE-CLARK
THE BASICS OF FUNCTION PLOTTING PAGE 4 / 5 proce
var
dure
;
begin := 1 to
for i
begin
9 do
end ;
end;
H&
R MAT
PUTE PASCAL
COM
ES IN
What to do? GAM
No plotting OK No plotting OK
DAVID
mes.
HOWARD PAGE-CLARK
THE BASICS OF FUNCTION PLOTTING PAGE 5 / 5 proce
var
dure
;
begin := 1 to
for i
begin
9 do
end ;
end;
H&
R MAT
PUTE PASCAL
COM
ES IN
procedure TForm1.plotbtnClick(Sender: TObject); GAM
A NEW HORIZON
FOR LAZARUS
AND FREE PASCAL
Figure 2
colorful and
therefor very
self explainng
DATABASE DESIGN
The Diagram Editor
supports two types of
diagramming:
conceptual and physical.
With a conceptual diagram ,
you're creating a purely
logical diagram: define domains for entity
attributes, logical entities and their relationships
including cardinality .
Entity attributes have common data types or are
based on a logical domain.
A conceptual diagram can be converted to a If you have existing databases and you want a
physical, database specific, diagram.
visual representation of it, just use the "reverse
Entities will be converted into tables, relationships
engineer" tool. You can move tables to sub-
into foreign key constraints and possible linking
tables.
diagrams for more clarity, modify table colors
The common data types and logical types will be or work with background regions for functional
converted to database specific data types and grouping.
domains, possibly with constraints. And when the database changes during
A physical diagram can be used to create the development, you can update the information in
actual database. the diagram from the modified database.
In the screenshot on the last page 24, Figure nr. 6 MAINTENANCE & ADMINISTRATION
you can see the staples ([)around BEGIN..END Got your application up and running?
blocks, current routine highlighting . Time to maintain it.
for INVOICE_ORDER and current block Modify the structure of
highlighting for the BEGIN..END in which the your database, print your
cursor resides. visual representation or
And code-folding in action can be seen for listing of meta data
function CREATE_INVOICE. objects for documentation
purposes and keep
TESTING AND DEBUGGING track of your changes by
When you're creating using the statement recorder. With Database
your database and your Workbench you can compare the database
application, it's time to structure of one database to another and see
start testing and debugging. what has changed.
Database Workbench There also is a Data Compare tool for those
includes a simple test data cases you need to compare the content of
generator (there's also a stand your database tables.
alone application available named Advanced
Data Generator, which can generate Via user and role management tools you can
complex real life like test data for you ) that create or edit database users.
allows you to generate street names, e-mail The Grant Manager allows you to grant object
addresses, personal and company names. privileges by point and click methodology,
By generating test data, you can fill your or by using grant templates to re-use your
database to test query response times, run your choice in privileges.
stored procedures and test your SQL views. Once again, there's no need to remember
When you use test data during development or specific SQL dialects , this is handled for you .
presentations, there's never the risk of private Depending on your database system, several
information slipping or testing with a-bit-too- monitoring tools are available to check on the
much-rubbish data entered by hand. performance of your server, specific databases
or queries that run for far too long.
Every query is executed according to a query
plan, with the visualized query plan and query
statistics you can see how your database system
is executing your query and adjust your SQL
accordingly.
The program “Database Workbench” includes a
stored procedure debugger for InterBase,
Firebird, Oracle, SQL Anywhere and MySQL.
You can execute your routines line by line to
check the logic in your code,
including viewing and settings variable values
while debugging.
Being a small company enables us to focus not only on our software, but also on our customers
and listening to their feedback when planning new features or products.
How it all started
Back in the Spring of 2001, Martijn Tonies published the early betas of a tool called "InterBase
Workbench" (later to be known under the name "Database Workbench") under the company
name of "Upscene Productions", a name he used for software tools he developed on the
Commodore 64.
As InterBase Workbench improved and users enjoyed the tool, things got official in May 2002,
the company "Upscene Productions" got registered.
In the years after that, the company established its name, the product line expanded and
potential customers keep finding our website.
Since then, Upscene Productions has proven to be a viable company, ready to support the latest
features in different database systems and enabling software developers to do their jobs as
efficient as possible.
29×37×127^(-1)×179×15749^(-1)×2082607
maxcalcF ('29*37*(127^-1)*179*(15749^-1)*2082607');
>> 199987.740088485
maxcalcF ('29*37*(127^-1)*179*(15749^-1)*2082607');
//#tech>perf: 0:0:1.190 threads: 6 192.168.56.1 12:49:55 4.2.2.95
//>>> 199987.740088485
ProcessHandle : THandle;
MemCounts : TProcessMemoryCounters;
ProcessID : DWORD;
ProcessHandle:= OpenProcess2(PROCESS_QUERY_INFORMATION or
PROCESS_VM_READ, false, ProcessID);
Sometimes conditional compilation apply to SonarQube is originally written for Java analysis
only a part of a statement. In that case, it is at PMD and later added C# and further support.
necessary to put the directives in line with the The SonarQube (web) server pulls the results
statement: from the database and provides a UI for
procedure MyOwnProc();
procedure MyOwnProc {$IFNDEF
(); {$IFNDEF BCB} ;
BCB} virtual reviewing and managing them, as well as a UI for
virtual;
{$ENDIF} {$ENDIF} managing configuration settings, user
procedure
procedure ClearClear; {$IFDEF
; {$IFDEF FPC}override;{$ENDIF} authentication, etc. The server also has its own
FPC}override;{$ENDIF} config file sonar.properties where you define
database settings, user authentication settings,
But that's just a simple solution because the etc. The monitor shows then the following topics:
computer world is full of incompatibility like
the following and last example: • Duplicated code
• Coding standards
// SOME REMARKS OF CR AND LF • Unit tests and Code Coverage
# On Mac, the newline is the CR
• Complex code
character (# 13)
# Windows , il se fait par • Potential bugs and issues
caractère CR+LF (#13+#10), Win it • Comments /API Documentation
is the character CR + LF (# 13 + # • Design and architecture
10)
# UNIX , par le caractère LF
(#10). , and on Unix, the LF (#
10).
• uncovered_complexity_by_tests
BYTE CODE PERFORMANCE
(it is considered that 80% of coverage
Intermediate representations such as byte-code
is the objective)
may be output by programming language
• function_complexity_distribution >= 8,
implementations to ease interpretation, or it
• class_complexity_distribution >=
may be used to reduce hardware and operating
60 package_edges_weight
system dependence by allowing the same code
CONSOLE CAPTURE DOS SONARQUBE51 to run on different platforms.
But then I want to test some Shell Functions on a So you can share your code as source in a
DOS Shell or command line output. The code normal text-file (*.txt) or as bytecocde
below allows to perform a command in a DOS (*.psb) to gain speed or obfuscation. In some
Shell and capture its output to the maXbox cases, you may want to export or deliver a script
console. First step with with its bytecode to store on removable media
Function or to use on a different
cyShellExecute(Operation,FileName,Parameters,Directory:String; computer without the
ShowCmd:Integer):Cardinal; source as a text-file.
function ShowFindFilesDlg(const Folder: string): Boolean;
begin
Result:= {mXCindyShellAPI.}cyShellExecute(
'find', PChar(Folder), '', '', {Windows.}SW_SHOW
) > 32;
end ;
This is how you can do that:
Next step is to capture the DOS output: 1. You open a script and compile it before.
The captured output is sent “real-time” to the 2. you go to /Options/Save Bytecode/ and
Memo2 parameter as console output in maXbox: the console writes:
-----PS-BYTECODE (PSB) mX4-----
srlist:= TStringlist.create; 13:48:38 -----BYTECODE
ConsoleCapture('C:\', 'cmd.exe', '/c dir *.*',srlist); saved as:
writeln(srlist.text) C:\maXbook\maxbox3\mX3999\maxbox3\examples\
srlist.Free; 287_eventhandliing2_primewordcount.psb
----IFPS#
But you can redirect the output srlist.text 3. you load the byte-code by
anywhere you want. For example you can /Options/Load Bytecode...
capture the output of a DOS console and
IFPS#
input into a textbox, or you want to
### mX3 byte code executed: 10.06.2015 13:53:20 Runtime:
capture the command start of demo app
0:0:1.577 Memoryload: 60% use ByteCode Success Message
and input into your app that will do
of: 287_eventhandling2_primewordcount.psb
further things.
ConsoleCapture('C:\', 'cmd.exe', '/c ipconfig',srlist);
ConsoleCapture('C:\', 'cmd.exe', '/c ping 127.0.0.1',srlist);
APPENDIX
“Wise men speak because they have something to say; Fools, because they have to say something”. -Plato
http://en.wikipedia.org/wiki/Coding_standard
Test Script:
http://www.softwareschule.ch/examples/615_regex_metrics_java2pascal.txt
COMPONENTS
4
8 monitor support, texture detection,
compression and clipboard sharing.
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.