Blaise 92 UK Compressed
Blaise 92 UK Compressed
Blaise 92 UK Compressed
ARTICLES
From Your Editor page 4
End To End encryption / By Chris Hoffman page 6
VirtualBox Problem / By Detlef Overbeek page 10
Cartoon / By Jerry king page 11
Max Box RSS Feeds of BBC News / By Max Kleiner page 12
Quantum Computing / By Detlef Overbeek page 16
A Combinations counter / By David Dirkse page 31
Hashi Logic Puzzles / By David Dirkse page 34
RegEx / By Michael van Canneyt page 41
Galactic Center Sonification /By M. Russo, A. Santaguida page 50
Code Snippets Find Easter Date / By Detlef Overbeek page 52
Code Snippets Icons on form / By Detlef Overbeek page 55
Web Service Part 1/ By Danny Wind page 60
Lazarus:New edition of the free version of WebCore for Mac page 70
By Mattias Gaertner
USB HID support in kbmMW #2 – 24×7 stability on Win10 page 75
DELPHI Revelations #6 – Delphi Bugs – Generics compiler bug page 81
By KimboMadsen
ADVERTISERS
The new LibStick page 5
Super Offer page 30
Subsription +Lazarus Handbook - hardcover page 40
Lazarus Handbook - Pocket (softcover) page 49
Delphi 10.4.2 available page 58
Barnsten Online FMX Power trainingen page 59
Subscription + Library USB Stick page 70
Delphi Company page 83
Componnets4Developers page 85/86
Pascal is an imperative and procedural programming language, which Niklaus Wirth designed (left below) in 1968–69
and published in 1970, as a small, efficient language intended to encourage good programming practices using
structured programming and data structuring. A derivative known as Object Pascal designed for object-oriented
programming was developed in 1985. The language name was chosen to honour the Mathematician, Inventor of the
first calculator: Blaise Pascal (see top right).
Niklaus Wirth Publisher: PRO PASCAL FOUNDATION in collaboration © Stichting Ondersteuning Programmeertaal Pascal - Netherlands
Holger Flick
holger @ flixments.com
Wim Van Ingen Schenau -Editor Peter van der Sman Rik Smit
wisone @ xs4all.nl sman @ prisman.nl rik @ blaisepascal.eu
Editor - in - chief
Detlef D. Overbeek, Netherlands Tel.: Mobile: +31 (0)6 21.23.62.68
News and Press Releases email only to [email protected]
Editors Correctors
Peter Bijlsma, W. (Wim) van Ingen Schenau, Rik Smit Howard Page-Clark, Peter Bijlsma
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 ( 2019 prices ) Internat. Internat.
excl. VAT incl. 9% VAT Shipment
Printed Issue
€ 155,96 € 250 € 80,00
±60 pages
Electronic Download Issue
€ 64,20 € 70
60 pages
Printed Issue inside Holland (Netherlands)
Member and donator of IKIPEDI W A
€ 240,00 € 70,00 Member of the Royal Dutch Library
±60 pages
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 or 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
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.
L I B R A R Y 2 0 2 0
89
90
87
88
86
85 51 52 53
84 50 54
55 49 26 27 28
83 29 25
48 56
81 30 24
82 47 9 10 11 57
12 31
80 46 23 8 1
2 13 32 58
78 22 7 3
79 45 14 33
21 4 59
77 44 6
20 5 15 34
75 60
76 43 19 16 35
18 17 61
73 42 36
74
41 37 62
72 40 39 38
71 69 63
70 67 64
68 66 65
procedure procedure
var var
begin begin
for I := 1 to 9 do for I := 1 to 9 do
begin Prof Dr.Wirth, Creator of Pascal Programming language begin
... ...
end end
end; end;
Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician
[email protected] Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician
BLAISE PASCAL
Blaise Pascal MAGAZINE
Magazine 92 2021
91 2021 7
END-TO-END ENCRYPTION PAGE 3/4
BLAISE PASCAL
Blaise Pascal MAGAZINE
Magazine 92 2021
91 2021 8
END-TO-END ENCRYPTION PAGE 4/4
This is a consequence of the fact that Apple However, if a ProtonMail user emails someone
holds the encryption key and can, from a using a different service, they’ll need to set up
technical perspective, do whatever it likes PGP to use encryption. (Note that encrypted
with your data. email doesn’t encrypt everything: While the
If Apple didn’t hold the encryption key for you, message body is encrypted, for example,
you wouldn’t be able to recover your data. subject lines aren’t.)
Imagine if, every time someone forgets a
password to one of their accounts, their data RELATED: What Is Signal, and Why Is Everyone
in that account would be wiped out and Using It?
become inaccessible.
End-to-end encryption is important.
Forget your Gmail password? Google would
have to erase all your Gmails to give you your If you’re going to have a private
account back. That’s what would happen if conversation or send sensitive
end-to-end encryption was used everywhere. information, don’t you want to make
sure that only you and the person
Examples of Services That Are End-to-End you’re talking to can see your
Encrypted messages?
BLAISE PASCAL
Blaise Pascal MAGAZINE
Magazine 92 2021
91 2021 9
VIRTUAL BOX PROBLEM
BBC News as our example provides feeds for This structure is a convention and suitable for a
both the desktop website as well as for our record:
type
mobile site and the most popular feeds are TRSSItem2 = record
listed here: FPubDate: TDate;
https://www.bbc.co.uk/news/10628494 FLink: string;
FTitle: string;
FDescription: string;
end;
First we define the URL to get the content
from:
Const
RSS_NewsFeed = 'http://feeds.bbci.co.uk/news/world/rss.xml';
RSS is an XML based document format for The FPubDate made me a bit upset because I
syndicating news and other timely news-like had to convert it in TRFC822DateTime Format .
information. This specified date-time value, while technically
It provides headlines, URLs to the source valid, is likely to cause interoperability issues.
document and brief description information in
an easy to understand and use format. The value specified must meet the Date and
RSS based “News Readers” and “News Time specifications as defined by RFC822, with
Aggregators” allow the display of RSS the exception that the year should be expressed
headlines on workstation desktops. as four digits.
Users of RSS content use apps called feed The syntax is like (all single spaced and no
'readers' or 'aggregators' (newer versions of comments):
Web browsers offer built in support for RSS
feeds): a user subscribes to a feed by entering <pubDate>Wed, 02 Oct 2020 08:00:00 EST</pubDate>
<pubDate>Wed, 02 Oct 2020 13:00:00 GMT</pubDate>
the link of the RSS feed into their RSS feed
reader;
There are two possible outcomes for the Superdense coding is the underlying
measurement of a qubit - usually taken to principle of secure quantum secret
have the value "0" and "1", like a bit or coding.
binary digit. The necessity of having both qubits to
decode the information being sent eliminates
the risk of eavesdroppers intercepting
messages.
Quantum computers connect qubits through a to the qubits. With a specific sequence of
quantum physics phenomenon called gates, called a circuit, quantum computers can
entanglement that lets a machine encompass perform computations for particular tasks like
an enormous number of possible solutions to simulating molecules or optimizing parts
a problem. purchases, which BMW is trying on its complex
supply chain.
Operating a quantum computer involves
applying a series of manipulations called gates
O
n 23 October 2019, Google AI , GOOGLE
in partnership with the after some troubles a new era of computing
U.S. National Aeronautics and Space seems to be here.
Administration (NASA), claimed to have Researchers at Google claim their quantum
performed a quantum computation that is computer has solved a problem that would
infeasible on any classical computer. take even the very best conventional machine
thousands of years to crack.
There are several models of quantum
computers (or rather, quantum computing The milestone, known as QUANTUM
systems), including the quantum circuit model, SUPREMACY, represents a long-sought stride
quantum Turing machine, adiabatic* quantum towards realising the immense promise of
computer, *(relating to or denoting a process quantum computers, devices that exploit the
or condition in which heat does not enter or strange properties of quantum physics to
leave the system concerned) speed up certain calculations.
It shows that quantum computing is really hard
but not impossible.
Figure 6:
Figure 9: Honeywell
w Connectivity of qubits
Lastly, connectivity is a key factor in
determining quantum volume.
Connectivity defines which pairs of qubits
can be entangled in a quantum computer.
Some hardware can directly apply
entanglement operations to any two
physical qubits in the system.
Other hardware can only operate on qubit
pairs that are physically located next to
each other.
When qubits are fully connected, they can
execute algorithms more efficiently,
solving problems with fewer steps and
taking full advantage of the qubits’ limited
coherence time.
Figure 10:
HONEYWELL ACHIEVED A QUANTUM VOLUME The figure of the plot at the bottom-left
OF 128 ON THEIR QUANTUM COMPUTER IN column shows the heavy outcomes for
LATE SEPTEMBER 2020. Honeywell Quantum Solutions’ tests of
What does that really mean? quantum volume and the dates when each test
Quantum volume is a metric that measures passed.
the capabilities and error rates of a quantum All tests are above the 2/3 threshold to pass
W A computer.
IKIPEDI
It expresses the maximum size of square quantum the respective Quantum Volume.
circuits that can be implemented successfully by Circles indicate heavy outcome averages and
the computer. the violin plots show the histogram
The form of the circuits is independent from the distributions. Data colored in blue shows
quantum computer architecture, but compiler can
system performance results and red shows
transform and optimize it to take advantage of the
computer's features. modeled, noise-included simulation data.
Thus, quantum volumes for different White markers are the lower 2-sigma error
architectures can be compared. bounds.
The system successfully passed the Quantum
In 2020, the highest achieved quantum volume Volume 128 test outputting heavy outcomes
(per § IBM's modified definition) rose from 32 for
IBM's computer "Raleigh" to 128 for Honeywell's 71.78% of the time, which is above 2/3
"H1",[2] i.e. quantum circuits of size up to 7×7 threshold with 99.934% confidence. The
have been implemented successfully. average single-qubit fidelity is 99.97(1)% and
the average two-qubit gate fidelity is
This and future increases in the capabilities of 99.54(7)% with fully-connected qubits.
quantum computers will empower customers
to achieve better and more results.
Scenario Simulation
Freight Forecasting
Irregular Behaviors (ops)
Disruption Management
Manufacturing
Quantum Chemistry
Materials Discovery
procedure procedure
var var
begin begin
for I := 1 to 9 do for I := 1 to 9 do
begin Prof Dr.Wirth, Creator of Pascal Programming language begin
... ...
end end
end; end;
[email protected]
Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician
https://www.blaisepascalmagazine.eu
L I B R A R Y 2 0 2 0
90
85
86
87
88
89
VIDEO
51 52 53
84 50 54
49 55
26 27 28
83 25 29
48 56
81 24
10 30
82 47 9 11
31 57
23 8 1 12
80 46
SUPER
2 13 32 58
78 22 7 3
79 45 14 33
21 4 59
77 44 6
5 15 34
OFFER (5)
20 60
75 19 16
76 43 18 17 35
73 61
74 42 36
41 37 62
72
€ 150 ex Vat
40 39 38 Quantum Computing / By Detlef Overbeek
71 69 63 Max Box / Max Kleiner
Fastreport / By Detlef Overbeek
70 67 64 MMX / By Detlef Overbeek and Dennis Zubov
68 66 65 Code Examples / By Detlef Overbeek
New Lazarus PJU Files for Mac By Mattias
Gaertner
free shipping
Installing a package on MacOs
RegEx / By Michael van Canneyt
Sample Project: Lazarus & Delphi Easter
ALL CODE ABOUT THE USE Holidays
Multi Tier a series for the web / By Danny Wind
Chess / By Detlef Overbeek
BLAISE PASCAL MAGAZINE
ALL ISSUES IN ONE FILE
PAGE-CLARK
HANDBOOK
FOR PROGRAMMING WITH FREE PASCAL AND LAZARUS
USING LAZARUS
procedure
;
var
begin
COMPUTER (GRAPHICS)
MATH & GAMES IN
934 PAGES PASCAL
The A elements can be placed in 2.1 = 2 In the later twentieth century, powerful and
sequences, the B elements in 3.2.1= 6 general theoretical methods were developed,
sequences which actually are the same if the making combinatorics into an independent
sequence is unimportant. branch of mathematics in its own right.
In general:
Writing 1.2.3….N as N! (called N faculty)
and the number of combinations of k choices
out of N elements as C(N,k) then C(N,k) = N!
/(k! . (N-k)!) because there are k elements
chosen and N-k element not chosen. Add, Shift, Backup
hashi written with another character, 箸, The circles are islands which have to be
means chopsticks). connected by bridges.
It has also appeared in The Times under the The number in the circle is the sum of bridges
name Hashi. In France, Denmark, the connecting to the island.
Netherlands, and Belgium it is published under A maximum of two bridges may connect two
the name Ai-Ki-Ai. islands. Bridges may not cross.
The puzzle is solved when all bridges have
RULES been installed and all islands are
Hashiwokakero is played on a rectangular grid interconnected.
with no standard size, although the grid itself Hashi puzzles exist in dimensions from 7x7 to
is not usually drawn. 25x25.
Some cells start out with (usually encircled) The difficulty ranges from easy to extreme.
numbers from 1 to 8 inclusive; these are the
"islands". The rest of the cells are empty. PASCAL DELPHI /LAZARUS PROJECT.
The purpose of this Hashi project is to:
The goal is to connect all of the islands by — Replace pencil, eraser and paper
drawing a series of bridges between the — Save and open puzzles
islands. The bridges must follow certain — Supply warnings
criteria: — Supply hints
— They must begin and end at distinct — Supply full solutions
islands, travelling a straight line in between. — Test for multiple solutions
— They must not cross any other bridges
or islands. Coding the puzzle
— They may only run orthogonally The puzzle is divided in squares (fields),
(i.e. they may not run diagonally). a field may contain:
— At most two bridges connect a pair of — nothing
islands. — An island
— The number of bridges connected to each — A horizontal bridge
island must match the number on that — A vertical bridge
island. type TFieldType = (ftNone,ftIsland,ftHbridge,ftVbridge);
The bridges must connect the islands into TField = record
a single connected group. ftype : TFieldType;
Idx : byte; //entry in island list
brCount : byte; //bridgecount for bridge and islands fields
end;
const maxgame = 15; //maximum game size 15x15
maxIsland = 100; //maximum number of islands
var game : array[1..maxgame,1..maxgame] of TField;
This supplies enough information to paint the In this list we see the neighbours vector
game, add/remove islands by mouseclicks, neighbrs[ ] which holds the island list index of
add/remove bridges by mouseclicks or – the 1 to 4 neighbours,
movements. Vector brConn[ ] holds the number of installed
A two dimensional array with hidden islands bridges for directions 1..4.
and bridges however is inconvenient to x,y are the coordinates of the island in the
generate warnings and hints or to recognize a game[ , ] array;
solved puzzle. The byte variable groupNr serves the checking
for a solved puzzle and also the recognition of
It is more convenient to have the islands an isolated island or group of islands. See later.
separately listed in an array.
NOTE:
the number of bridges to install is the sum of
all islands bridge counts divided by two.
So, if this sum is odd, the puzzle cannot be
solved.
All islands are placed in an Island[ ] list.
Picture below shows an island with 4
neighbours:
37
HASHI LOGIC PUZZLES Page 5/6
In this case bridge selections 01 and 10 are the Hints and warnings are painted directly on
same, so counting must be 00,10,11 skipping paintbox1 of form1.
the 01 selection.(do not select bridges, select
1 bridge, select both bridges). The effect of events from keyboard, mouse or
Byte array CC[ ] is the combinations counter. buttons depends on the gamestate.
1: bridge; 0:no bridge Type TGamestate =
Next picture shows what to do after a CC (gsInitial,gsNew,gsPlaying,gsHintWait
ing,gsSolving);
counter update:
gsNew: allows adding/removing islands in
game[ , ]
gsPlaying : allows adding/removing bridges,
selection of warnings and hints.
gsHintWaiting: a hint is found, waiting for
user decision: install or neglect.
gsSolving: searching for solution in
progress.
For each new combination in CC bridges are Gamestates are updated by procedure
added/removed from the island list and controlmessage(cm : Tcontrolmesage)
game[ , ] This is the central place to change the
Then a check for solution is made. The gamestates.
number of bridges in the bridgelist is limited to Mouse- and keyboard events and also button
40 to avoid extremely long processing times. clicks call the controlmessage procedure with
a message indicating the originator. Then the
Multiple solutions controlmessage procedure, after approval,
These are simply checked by generating more calls a specific procedure to do the job.
combinations and testing for solutions. Procedure controlmessage in fact is a table
When the last combination is reached, like construct of case statements:
no more solutions are possible. Imagine the gamestate as row, the message
type as a column.
This Delphi/ Lazarus project. This structure may look exaggerated at first
The menu buttons are supplied by the (why not performing functions directly in
TDavArrayBtn component, see my Math and the event methods) but centralizing control
Delphi programming book. adds to the clearness and increases
maintainability. The project has 6 units:
The gamesize selection is made by a
TDavRotation button component, which Unit1:
imitates buttons found on labotory equipment. event handling, control,
See an earlier publication. adding/removing islands
Game_unit:
Space in this article is limited so I do not show
for testing of a solved puzzle, warning
code, please refer to the Delphi project.
and hints, adding or removing bridges
Variable gamesize holds the selected size of Paint_unit:
the Hashi puzzle. painting procedures for Gmap bitmap
Array game[1..15,1..15] uses only fields Solve_unit:
1..gamesize. procedures to solve a puzzle by brute
The game is painted in bitmap Gmap, which is force, combinations counter
created in the onCreate event. Progress_unit:
Gmap is copied to Paintbox1 to become procedures to make progress bar in
visible. paintbox progressbox on form1
IO_unit:
procedures to save and open puzzles.
ARBOORUSOK
CSS Styles / Progressive Web Apps
Android / IOS / Mac / Windows & Linux
AL
Z PA
SC
LA ND AZA BO
EE
FR
H AL
LAZARUS HANDBOOK 1
IT SC
W PA
HA L AND
G EE
IN FR
MM
LAZARUS HANDBOOK 2
H
GRA W
IT
O
PR NG
R MI
FO
H FO
R
PR
OGR
AM
an
Ca Oue
l v ssa ee
ae ou erb
ich r In Ov
k
t,
ey ng
nn dra
o,
2 Bla
ise
Pa
sca
l
Quantum Computing / By Detlef Overbeek
Max Box / Max Kleiner
Fastreport / By Detlef Overbeek
MMX / By Detlef Overbeek and Dennis Zubov
Code Examples / By Detlef Overbeek
New Lazarus PJU Files for Mac By Mattias
Gaertner
Installing a package on MacOs
RegEx / By Michael van Canneyt
Sample Project: Lazarus & Delphi Easter
rs : Mrtne tlef
o Gä D e
Holidays
th ,
Au ttias inig
e Multi Tier a series for the web / By Danny Wind
Ma n H
Sv
e
Chess / By Detlef Overbeek
Subscription
Combi (4)
Subscription + Lazarus Handbook
(hardcover)
100
Ex Vat 9%
Including shipment !
REG EX USED IN PASCAL PAGE 1/8
By Michael van Canneyt
ABSTRACT
Regular expressions should be a part of every
programmer’s toolbox. Once grasped,
they are easy to use
and can accomplish otherwise
REG EX difficult or time-consuming
tasks for you.
A short introduction
q N(S) f
& PASCAL
starter
in Regular Expressions.
expert
Still, surprisingly many people do not know how define a search pattern. Usually such patterns
to use them. Therefor we give a simple are used by string-searching algorithms for "find"
or "find and replace" operations on strings, or for
introduction on how to use them. input validation. It is a technique developed in
In what follows, the POSIX conventions for theoretical computer science and formal language
regular expressions are described. theory.
Some editors and IDEs use slightly different
conventions. The concept arose in the 1950s when the
American mathematician Stephen Cole Kleene
A good overview of all possibilities (and in formalized the description of a regular language.
particular the Perl Compatible Regular The concept came into common use with Unix
Expressions (PCRE)) can be found on the text-processing utilities. Different syntaxes for
wikipedia page: writing regular expressions have existed since
https://en.wikipedia.org/wiki/Regular_expression
the 1980s, one being the POSIX standard and
another, widely used, being the Perl syntax.
In the IDE you will usually want to use the Keep the list selected, and in the search and
replace functionality when using regular replace dialog, you can enter the following:
expressions. F{.*} : {.*};
This will match all field definitions in the
When you want to replace the found matches selection.
with something else, you will most likely want Because we used the grouping operators,
to refer to part of the matched term in your we can use the group in the replace text:
replacement text. \0 := Src.\0;
In order to do so, you can use the { } brackets This will replace something like
to group particular parts in your expression. FFirstName : String;
You can refer in your replacement text to these With:
groups by \0 to \9 . FirstName := Src.FirstName;
When we hit ’Replace all’ the IDE will do all
A good example where this can be useful is the replacements, and the result can be seen in
Assign method, which must be implemented figure 4 on page 4/8 of the article, page 44 of
in descendants of TPersistent to copy all the issue.
properties from one to another instance.
There is also an open source all-native Object The G modifier: turn on greedy matching.
— ModifierM (boolean)
Pascal implementation of regular expressions:
https://github.com/andgineer/TRegExpr The M modifier: enables multiline mode.
It is implemented by Andrey V. Sorokin, In that mode, the ˆ and $ characters
has been around for a long time, works for all match the beginning and end of each line in
versions of Delphi, and also for Lazarus/Free the search text, not just the beginning and
Pascal. end of the whole search text.
In fact, Free Pascal ships with a version of — ModifierX (boolean)
TRegexpr. Therefor, we’ll use this The X modifier: Allows you to use
implementation to demonstrate how regular comments in your regex using the
expressions can be used. # character.
When we find a match, we use the MatchPos This time we use a Delphi program. We drop 2
and MatchLen properties to set the selection TMemo components on it, one for the template
of the memo. (note that Matchpos is 1-based, (MTemplate), one for the result (MResult).
and SelStart is 0-based) If no match is found, We also drop a TValueListEditor
we show a message, but we don’t close the on the form. Here the user can enter the values
dialog. for the template variables. Last item is a
button (Generate) to generate the final text
NOTE that if the user based on the template and the user-provided
changes the text between searches, the matches variables and their values.
will no longer correspond to actual positions, The OnClick event of the button is
so in a real program, it would be best to make implemented with the ReplaceEx call:
the memo readonly while the search is active.
procedure TMainForm.GenerateClick(Sender: TObject);
The result of this can be seen in figure 6 on Var
page 7/8 of the article, page 47 of the issue. Regex : TRegexpr;
To demonstrate the power of the TRegexpr begin
Regex:=TRegexpr.Create;
class, we’ll also implement a small algorithm try
that transforms a template text with some data Regex.Expression:='\{\{[^{}]*\}\}';
placeholders to a ready-to-read text: a kind of MResult.Lines.Text:=
Regex.ReplaceEx(MTemplate.lines.Text,
mailmerge, or the kind of functionality often ReplaceCallback);
found in templating engines such as Mustache. finally
A template engine such as Mustache will replace Regex.Free;
end;
a template {{SomeVariable}} end;
with the value of SomeVariable. Usually more
complex logic is also available, but for this
example, we limit ourselves to simple variables,
which are kept in a Key=Value list.
S
ARU
LAZARUS HANDBOOK
S
RU LAZ
AZA ND
LAZARUS HANDBOOK 2
DL L A
AN CA
AL PAS
ASC REE
EP ITHF
FRE
LAZARUS HANDBOOK 1
W
ITH ING
GW MM
MIN ROGRA
AM P
GR FOR
PRO
FOR
+ 9 34
PA
GE
S
INCLUDED:
bookmark - creditcard - usb stick
which contains the personalized pdf
file of the book and the extra program files. So 934 pages
in two books
you have your electronic as wel the printed book
in one product.
https://chandra.si.edu/photo/2020/sonify/
sonify_galactic_all.mp4
INTRODUCTION:
Sonification is the process that translates data
into sound, and a new project brings the
center of the Milky Way to listeners for the
first time.
The translation begins on the left side of the
image and moves to the right, with the sounds
representing the position and brightness of
the sources.
The light of objects located towards the top of https://chandra.si.edu/photo/2020/sonify/
sonify_casa_all_at_once.mp4
the image are heard as higher pitches while
the intensity of the light controls the volume.
R USOK S R USOK S
ZADBOARUOOK ZADBOARUOOK
S
AL AL RU
SC SC ZA
PA PA LA
A
L N AZ B W
IT
H
FR
EE
PA
SC
AL
A
L N AZ B W
IT
H
FR
EE
PA
SC
AL
PAS
CA
LA
ND
HA L AND HA L AND
G EE G EE EE
LAZARUS HANDBOOK
IN FR IN FR
MM H MM H FR
RA IT RA IT TH
OG G
W OG G
W WI
PR IN PR IN G
IN
R MM R MM
FO
H FO
R
PR
OG
RA FO
H FO
R
PR
OG
RA
FO
R
PR
OG
RA
MM
+
u th s G ig, D
A ttia in
Ma n H
Sv
e
e
an
l v ssa ee
ae ou erb
ich r In Ov
: M ne tlef
ors ärt e
k
t,
ey ng
nn dra
Ca Oue
o,
2 Bla
ise
Pa
sca
l
th
Au ttias inig
Ma n H
Sv
e
e
,
an
l v ssa ee
ae ou erb
ich r In Ov
: M ne tlef
ors Gärt De
k
t,
ey ng
nn dra
Ca Oue
o,
2 Bla
ise
Pa
sca
l
4
PA
GE
S
93
HardCover (3)
934 Pages
75 euro ex Vat
including shipment in two books
including. PDF
https://www.blaisepascalmagazine.eu/product-category/books/
D := B DIV 4;
E := B MOD 4;
F := (B + 8) DIV 25;
G := (B - F + 1) DIV 3;
H := (19 * A + B - D - G + 15) MOD 30;
I := C DIV 4;
J := C MOD 4; Figure 3: Google Eggs
K := (32 + 2 * E + 2 * I - H - J) MOD 7;
L := (A + 11 * H + 22 * K) DIV 451; Google had a nice easter logo which I used
M := (H + K - 7 * L + 114) DIV 31;
N := (H + K - 7 * L + 114) MOD 31; here. And now the funny part comes: the
project was developed in Delphi and then
vDay := N + 1; converted to Lazarus. But I did not have the
IF M = 3 THEN vMonth := 3 ELSE vMonth := 4;
Result := EncodeDate(aYear, vMonth, vDay); original file, so I had to recreate it, and if
END; possible make it a even „better“.
try
If OpenDialog1.Execute
Then Image1.Picture.LoadFromFile(OpenDialog1.FileName);
Caption := 'Icon found at Path: ' + OpenDialog1.FileName;
// Show in the caption area the path
Except
MessageDlg('Loading the icon failed', mtError, [mbOK], 0);
End;
end
else if Trackbar1.Orientation = trVertical
then
begin
Trackbar1.Orientation := trVertical;
BtnLoadWin.left := + 4;
BtnLoadWin.width := (BtnLoadWin.Width + 26);
BtnOSx.left := + 4;
BtnOSx.width := (BtnOSx.Width + 26);
BtnSearch_Icon.left := + 4;
BtnSearch_Icon.Width := (BtnSearch_Icon.Width + 26);
BtnFormIco.left := + 4;
BtnFormIco.width := (BtnFormIco.width + 26);
Btn_Hor_Vert.left := + 4;
Btn_Hor_Vert.width := (Btn_Hor_Vert.Width + 26);
Trackbar1.Orientation := trHorizontal ;
end;
end;
procedure TFrmGUI.UpdateTrackBar;
begin
if TrackBar1.Enabled then
begin
TrackBar1.Min := 0;
TrackBar1.Max := 160;
TrackBar1Change(TrackBar1);
end; In the example of the code at the left is the
code written for making sure you can see the
Button width will be changed if you have the
track bar horizontally activated or vertically.
The option Load from OSx is not available
because Delphi does not run on other OSx
UpdateTrackbar;
end;
You can load a
procedure TForm1.BtnOSxClick(Sender: TObject);
png file or what begin
ever bitmaps. The Image1.Picture.LoadFromFile(ExtractFilePath
(ParamStrUTF8(0)) + 'icons' + PathDelim +
result will however
'lazarus.icns');
be always an icon. Caption := 'Icon found at '
Lazarus has + S + 'icons' + PathDelim + 'lazarus.icns' ;
procedure TForm1.BtnSearch_IconClick
(Sender: TObject);
begin
Try
If OpenDialog1.Execute
Then Image1.Picture.LoadFromFile
(OpenDialog1.FileName);
Caption := 'Icon found at ' + ' Path: '
+ OpenDialog1.FileName;
Except
MessageDlg('Loading the icon failed', mtError, [mbOK], 0);
End;
UpdateTrackbar;
end;
procedure TForm1.UpdateTrackBar;
begin
TrackBar1.Enabled :=
Image1.Picture.Graphic is TCustomIcon;
if TrackBar1.Enabled then
begin
TrackBar1.Min := 0;
TrackBar1.Max :=
TCustomIcon(Image1.Picture.Graphic).Count - 1;
TrackBar1.Position :=
Here is the loaded TCustomIcon(Image1.Picture.Graphic).Current;
icon from OSX TrackBar1Change(TrackBar1);
end;
end;
Overzicht trainingen
Some Open Source web service frameworks We will not be using these existing frameworks,
MARS Curiosity Framework: instead we will be building a simple web
https://github.com/andrea-magni/MARS service server and client from scratch.
mORMot ORM Framework
https://github.com/synopse/mORMot STARTING THE BUILDING OF THE PROGRAM
WiRL RESTful library on the next page we will create the web service
https://github.com/delphi-blocks/WiRL client.
12. When you use an URL to a REST endpoint from an existing Web Service,
you get JSON data. Try this URLs in the Web Service Client
https://api.discogs.com/artists/457265
13. The result is JSON data, recognizable due to the curly braces {}
14. The next step is to create our own Web Service Server
15. We start with the New Item wizard for Web | Web Server Application
Figure 8: VCL
19. VCL is OK
20. Test if the default port is not already taken on your machine.
If it is you can Find Open Port or just try another port, such as 8088 or 8888.
21. Save the files into a separate directory and save the Project as WebServiceServerGUI
24. Make note of the URL that is then opened in the web browser
http://localhost:8080/
25. Run the Web Service Client and open this URL.
26. The :8080 in this URL is the internet port. An internet port is like a door, each door has its
own number. If the port is opened in the firewall, traffic is allowed through.
27. The localhost in this URL translates to a loopback to this machine. It’s translated to a local
IP address (127.0.0.1) that points to the machine you are running on.
Figure 12: Run the Web Service Client and open this URL.
28. This is the default handler for the Web Server Service
29. Let’s add a new GET handler to the Web Server Service
30. Open the Web Server Service GUI project and open the WebModuleUnit
Figure 14:
34. Run the Web Service Server, and Start it with the Button
35. Now open the Number URL in the Web Service Client
http://localhost:8080/Number
36. Request a couple of random numbers in the Web Service Client
Figure 16:
38. See here also for a brief description of JSON structures
https://www.json.org/json-nl.html
You already have the basis for your own Web Service. You can use this code for example to use the
values from your own weather station via GET requests available and displayed in an Android App.
In the following articles, we will change data in the Web Service by adding a PUT, POST and DELETE.
We will also use more complex JSON structures.
You can download the source code for this article from your subscription webpage:
https://www.blaisepascalmagazine.eu/your-downloads/
WEB
macOS free
TMS WebCore tms
Figure 1: Logo
INTRODUCTION:
We have been developing the free version of
TMS WebCore and that worked fine for Windows
and for Linux. macOS was however a problem. Figure 2/3: the warning that is of no use...
Not because we could not install it, but because NOW BACK TO macOS.
of the manifold popping up of warnings and Here you need to prepare for the usual steps:
requests to accept to use your password.
Up to 8 times per install. That is ridiculous. 1. Install your macOS version of Lazarus.
So we decided to find a way to get it done We have tested this with the version
without all that hassle. Apple has still its very 2.0.11(the latest version was not available
own ideas of protecting and User Interface. yet by writing this article…). The version is
I had promised that about three months a go. a so called trunk version, but works no
It’s a long way to Tipperary, an old song and other than 2.010
especially this project needed quite some time.
But we have solved it. Here is the story of how 2. Download the version of TMS Webcore for
to install it. free from our website or this address
http://downloads.blaisepascal.eu/
The version is downloadable for free from: TMSWebcoreLazarusDemoFree1.5.4.zip
http://downloads.blaisepascal.eu/ (See figure 6 at page 1/7 or issue page 71)
TMSWebcoreLazarusDemoFree1.5.4.zip
By the way: now you also can download the 3. You also need to collect your License
latest stable update(no new features only bugs number: it’s for free available at:
https://www.tmssoftware.com/site/
reduction) of Lazarus from: trialkey.asp
https://sourceforge.net/projects/lazarus/
files/Lazarus%20Windows%2064%20bits/
Lazarus%202.0.12/ 4. Now unzip the download to a directory of
lazarus-2.0.12-fpc-3.2.0-win64.exe/download your choice
or go to:
https://www.lazarus-ide.org/ 5. Start Lazarus
(see figure 4 on the next pageÚ2/4 or 71) 6. Go to Package Ú Open Package file (lpk)
Once you have done this we can start the Úselect in the directory of your choice
installation of the package. First of all: the tmswebcorepkgliblaz.lpk .
installation under Win10 responds with a That file will handle the other .lpk files
message of distrust. Don’t worry, simply click on as well. The package window opens.
the more info text. In the next screen you can
simply run it.
Figure 11:
After that you need to
save the license in that
directory
89
90
87
88
86
85 51 52 53
84 50 54
49 55 26 27 28
83 29 25
48 56
81 30
24
82 47 9 10 11 57
12 31
80 46 23 8 1
2 13 32 58
78 22 7 3
79 45 14 33
21 4 59
77 44 6
20 5 15 34
75 60
76 43 19 16 35
18 17 61
73 42 36
74
41 37 62
72 40 39 38
71 69 63
Quantum Computing / By Detlef Overbeek
70 67 64 Max Box / Max Kleiner
68 66 65 Fastreport / By Detlef Overbeek
MMX / By Detlef Overbeek and Dennis Zubov
Code Examples / By Detlef Overbeek
New Lazarus PJU Files for Mac By Mattias
Gaertner
Installing a package on MacOs
ALL CODE ABOUT THE USE RegEx / By Michael van Canneyt
Sample Project: Lazarus & Delphi Easter
Holidays
BLAISE PASCAL MAGAZINE Multi Tier a series for the web / By Danny Wind
ALL ISSUES IN ONE FILE Chess / By Detlef Overbeek
procedure procedure
var var
begin begin
for I := 1 to 9 do for I := 1 to 9 do
begin Prof Dr.Wirth, Creator of Pascal Programming language begin
... ...
end end
end; end;
Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician
[email protected] Prof Dr.Wirth, Creator of Pascal Programming language Blaise Pascal, Mathematician
https://www.blaisepascalmagazine.eu
1 year Subscription+
the new LibStick
(on USB Card - 90 Issues)
70
ex vat / inc. shipment
USB HID support in kbmMW
#2 – 24×7 stability on Win10 Page 1/6
By Kim Bo Madsen
HOW TO IMPROVE STABILITY OF YOUR USB HID
DEVICES ON WIN10
I’ve noticed when attaching a barcode scanner like
the Honeywell 1300g to the USB port of a computer
running Win10, the scanner works perfectly….
for as long as it is being used, or some additional
hours, until power save mode or a Windows house
keeping kicks in.
Figure 4:
Change USB selective suspend settings to DISABLED
2. On the specific USB driver in device
Figure 6: Locate
management. Some USB device drivers allows
for defining their power save settings. In the device manager, locate the Universal
Serial Bus controllers section. Each of the USB
Open the device manager hub entries usually have power save options
you can tune or turn off.
Do that for at least the USB hub which you
connected the device to, but I recommend to
do it for all USB hubs to avoid problems if you
one day choose to plug in the USB device into
another port on your computer, which may be
driven by a different built in USB hub.
Right click the USB hub entries, one by one, BUT IT DIDN'T REALLY SOLVE THE PROBLEM
and click Properties After disabling power saving features for the
USB (which is a requirement to do to get a
stable, always running USB device).
I however still experienced problems when the
devices were not used over night.
Browse
Include subfolders
Select the device driver you want to install for the hardware
Select the manufacturer and model of your hardware device, then click Next.
Click Have Disk / CD if an installation disk came with the hardware
Next Cancel
DefineData can be told to manage the data Finally UndefineAllData removes all data
provided for it, meaning it is responsible for definitions regardless of names. The second
freeing the data when it is no longer used by instance of TMyObject ought to disappear
the binding framework, which is a powerful here, but alas it did not.
way to leave the responsibility of the lifetime
of the data to SmartBind ….. if it only worked! So OBVIOUSLY there must be a bug in
I discovered that despite my best efforts, DefineData and UndefineAllData.
the data were not automatically freed.
But no, that is not the case.
I looked high and low to made sure that the
intricate internal routines handling all this,
The problem in this case is that the compiler
actually worked, before I realized what the
chooses the wrong overloaded method when
problem was.
it compiles the code.
First some test code showing the use of
DefineData where I noticed it failing:
Stepping into the code, I realised that I
(See right top). stepped into the one with this signature:
function DefineData<T>(const AName:string; const [ref] AData:T; const AAsReference:boolean):TValue;
Basically I create a simple object, defined it to Which you can see is a generic version, and
SmartBind with the argument true, thus should not be selected unless I had used
meaning that SmartBind must take the syntax: Únext page
ownership of the object instance.
Then I created a new one and defined that
under the same name as the previous one,
which should result in the previous TMyObject
should be freed, which did not happen.
Binding.DefineData<TObject>('object',o,true);
newer is a prerequisite to this update. * Changed default SQLite memo field type to CLOB.
If preprocessor conditional KBMMW_FIX_SQLITE_MEMO_BUG is
This is a combined bugfix and selected new features defined, then CreateOrUpgrade will automatically attempt modifying
release.The release includes: existing tables old MEMO status to CLOB. Prevents unintentional
interpretation of numeric look a like values as numerics.
New stuff
New HTTP and kbmMW server status message - Added support for status methods in
handling support in Smart services kbmMWCustomSmartService and
kbmMWCustomHTTPSmartService. Status methods are smart
— New support for methods that are only triggered when an error or warning status
TkbmMWGenericMagneticStripeReaderHID and is happening. They take both kbmMW native status codes and
TkbmMWGenericBarcodeReaderHID HTTP status codes.
Updated RESTFishFact demo to show examples of how to use.
— New support for pivot based counters in the
- Added QueuedAfterRun and QueuedAfterEnd methods to
ORM kbmMWScheduler.
— New support for transport native file sending for - Added ConcatBytes and BytesZ2String to
HTTP.Sys transport kbmMWPlatformMarshal.
— New support for automatic GZIP compression of - Added global kbmMWCoalesce and kbmMWIsSameVariants
responses from HTTP Smart services global functions in kbmMWGlobal.pas.
— Several feature improvements and fixes. - Added internal thread locking to TkbmMWMemoryStream.
- Added DeleteByName, IndexOfvalue, ContainsValue to
Please check the end of this post for a detailed
TkbmMWHTTPCustomValues.
change list. - Added new TkbmMWMimeTypes class to kbmMWHTTPUtils.pas.
Supports specifying if a mimetype is compressible.
Professional and Enterprise Edition is available for all - Updated compiletool to optionally allow creation of project files
with a current active SAU. If your SAU has run out, for non installed compilers.
please visit our shop to extend it with another 12 - Improved HID support with
months. TkbmMWGenericMagneticStripeReaderHID,
TkbmMWGenericBarcodeReaderHID and added various more
methods like Manufacturers, Products and
Community Edition (CE) can be used as a 60 day ManufactorersAndProducts to extract basic data.
trial, alternatively as a free product, provided the - Added support for pivot based counters in the ORM and
license is followed. connection pool.
Please read license.txt file for details. CE supports a - Added support for transport native file sending for HTTP.Sys
large subset of the Enterprise Edition features, but transport. Will automatically trigger when using
may have technical and artificial limitations in certain HTTPResponseFromFile.
- Added support for automatic GZIP compression of responses
areas. It only supports a specific Delphi/Win32 SKU,
from HTTP Smart services, provided client announce support of it
produce Win32 executables and do not include in call.
source.
Fixes
Please visit - Fixed kbmMWDebugMemory compilation.
https://portal.components4developers.com to - Fixed precise scheduled event shutdown bug.
download. - Fixed SQL rewriting of ALTER TABLE ALTER/MODIFY COLUMN
for ANSI92 and subsequently for IB, MYSQL and ORACLE.
- Fixed exception in kbmMWCustomDataset.pas when
kbmMW is the premiere n-tier product for Delphi, attempting to run nil cursor thru a piped kbmSQL statement.
C++Builder and FPC on Win32, Win64, Linux, Java, - Improved SmartBinding, fixed bugs and stability.
PHP, Android, IOS, .Net, embedded devices, - Fixed SmartBinding bugs for Android.
websites, mainframes and more. - Fixed bugs in kbmMWDateTime related to local date conversion.
- Fixed bug in TkbmMWTCPIPIndyMessagingClientTransport which
Please visit http://www.components4developers.com would cause package data corruption upon IsConnected checking
from a different thread.
for more information about kbmMW.
Changes/minor additions
Components4Developers is a company established in - Refactored and introduced kbmMWCore.pas
1999 with the purpose of providing high quality kbmMWCore.pas amongst others contains TkbmMWInterlocked.
development tools for developers and enterprises. - Added a number of KBMMW_TRANSPORTSTREAM_PARAM_xxxx
The primary focus is on SOA, EAI and systems constants for setting up transport stream parameter options.
integration via our flagship product kbmMW. - Changed SynchronizedAfterRun and SynchronizedAfterEnd back
to not queueing.
- Changed default SQLite memo field type to CLOB.If preprocessor
kbmMW is currently used as the backbone in conditional KBMMW_FIX_SQLITE_MEMO_BUG is defined, then
hundreds of central systems, in hospitals, courts, createOrUpgrade will automatically attempt modifying existing
private, industries, offshore industry, finance, tables old MEMO status to CLOB. Prevents unintentional
telecom, governments, schools, laboratories, interpretation of numeric look a like values as numerics.
rentals, culture institutions, FDA approved medical - Improved TkbmMWPathMatcher to handle escaped characters.
devices, military and more. Will allow for $ and ^ in URL paths for example.
Escape by backslash.
- Improved support for IInterface in kbmMWRTTI.pas
COMPONENTS
DEVELOPERS 4 DX
EESB, SOA,MoM, EAI TOOLS FOR INTELLIGENT SOLUTIONS. kbmMW IS THE PREMIERE N-TIER PRODUCT FOR DELPHI / C++BUILDER