BlaisePascalMagazine 44 UK

May 10, 2018 | Author: Thotsaphon Chaiyachet | Category: Euclid, Euclidean Geometry, Technology, Computing, Mathematics
Share Embed Donate


Short Description

O V E R V I E W O F D E L P H I T O D E L P H I H I S T O R Y E U C L I D E S A N A G E P U Z Z L E B Y D A V I D D I...

Description

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 M O B I L E, 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 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

BLAISE BLAISE PASCAL PASCAL MAGAZINE MAGAZINE 44

OVER VIEW OF DELP HI TO DELP HI HISTOR Y EUCLIDES AN AGE PUZZ LE BY DAVID DIRKS E 

ARDU INO: THE VISUI NO PROJECT - PART 4 INTE RNET OF THIN GS - WIT H ARDU INO AND DELP HI USE ETHERN ET SHIELD, PROGRA M IT WITH VISUINO , CONN ECT FROM A DELPH I APPL ICATION OVER THE LOCAL NETWORK OR INTERNET BY BOIAN MITOV

DATA BASE WORKBE NCH 5 THE SWISS ARMY KNIFE FOR DATABASES BY PET ER VAN DER SMAN

TIPS AND TRI CKS WITH KBMMEMTAB LE BY KIM MADS EN 

PRIN TED ISSUE PRICE € 15.00 DOW NLOA D ISS UE PRI CE

€ 7.50

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

O B I L L A N D O W S

E S T U D G U A G & L I N U X

I E

O, S

CONTENTS Articles OVER VIEW OF DELPH I TO DELPHI HISTO RY EUCLIDES AN AGE PUZZ LE

PAGE 6 PAGE 7 PAG E 8

BY DAVID DIRKS E 

ARDU INO: THE VISUI NO PROJECT - PART 4 INT ERNET OF THINGS - WIT H ARDU INO AND DELP HI USE ETHERNE T SHIELD, PROGRAM IT WITH VISUI NO, CONN ECT FROM A DELP HI APPLICATION OVER THE LOCAL NETWORK OR INTERNET

PAGE 12

BY BOIAN MITOV

DATA BASE WORKBE NCH 5 THE SWISS ARMY KNIFE FOR DATABASES PAGE 28

BY PET ER VAN DER SMAN

TIP S AND TRICKS WITH KBMMEMTA BLE BY KIM MADSE N 

PAG E 39

Advertisers BETTER OFFICE COMPONENTS 4 DEVELOPERS 48 COMPUTER MATH MATH & GAMES 4/5 DANIEL TETI DELPHI COOKBOOK 11 EVERS 36 NEW BLAISE LIBRARY 38 PASCON DELPHI 37 UPSCENE 35 VISUINO MITOV 27

2

Publisher: Foundation for Supporting the Pascal Programming Language in collaboration with the Dutch Pascal User Group (Pascal Gebruikers Groep) © Stichting Ondersteuning Programmeertaal Pascal

Issue Nr 6 2015 BLAISE PASCAL MAGAZINE

Stephen Ball http://delphiaball.co.uk @DelphiABall Marco Cantù www.marcocantu.com   marco.cantu  marco.can tu @ gmail.com  gmail.com 

Peter Bijlsma -Editor peter @ blaisepascal.eu

Michaël Van Canneyt,  michael @ freepasca freepascal.org l.org

David Dirkse www.davdata.nl E-mail: David @ davdata.nl

Benno Evers  b.evers @everscustomtechnology.nl Cary Jensen www.jensendatasystems.com  http://caryjensen.blogspot.nl

Bruno Fierens Primož Gabrijelčič www.tmssoftware.com  www. gabrijelcic.org c.org  m   primoz @ gabrijelci  m   bruno.fierens  bruno.fie rens @ tmssoftware. tmssoftware.co co John Kuiper [email protected]

Wagner R. Landgraf  wagner @ tmssoftware.com 

Kim Madsen www.component4developers

Peter van der Sman [email protected]

Jeremy North

Detlef Overbeek - Editor in Chief  www.blaisepascal.eu editor @ blaisepascal.eu

Howard Page Clark E-mail: hdpc @ talktalk.net

Andrea Raimondi

Wim Van Ingen Schenau -Editor wisone @ xs4all.nl

Rik Smit rik @ blaisepascal.eu

Bob Swart www.eBob42.com Bob @ eBob42.com

Max Kleiner www.softwareschule.ch  [email protected]   max@kleine r.com 

jeremy.north @ gmail.com 

Daniele Teti www.danieleteti.it [email protected]

Please note: extra space characters have been deliberately added around the @ symbol in these email addresses, which need to be removed if you use them.

editor @ blaisepascal.e blaisepascal.eu u Authors - Christian name in alphabethical order A B C D F G H J

Andrea Raimondi , Stephen Ball, Peter Bijlsma, Dmitry Boyarintsev Michaël Van Canneyt, Marco Cantù, David Dirkse, Daniele Teti Bruno Fierens Primož Gabrijelčič, Mattias Gaertner Fikret Hasovic Cary Jensen

L K M N O P S Z

Wagner R. Landgraf, Sergey Lyubeznyy Max Kleiner Kim Madsen, Felipe Monteiro de Cavalho Jeremy North, Inoussa Ouedraogo Howard Page-Cla Page-Clark, rk, Rik Smit, Bob Swart, Siegfried Zuhr

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: version: subscription subscription € 65.-- Incl. VAT VAT 6 % (including (including code, programs programs and printed magazine, 10 issues per year excluding postage). 2: Electronic - non printed printed subscription subscription € 45.-- Incl. VAT VAT 21% (including code, code, programs programs and download magazine) 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 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 Foundation-Foundation for Supporting the Pascal Programming Programming Language (Stichting Ondersteuning Programeertaal 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 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.

Issue Nr 5 2015 BLAISE PASCAL MAGAZINE

3

DAVID DIRKSE presales at www.blaisepascal.eu/DavidDirkse/ComputerMath_Games.html

 procedure ;  procedure ;  var  begin for i := 1 to 9 do  begin end  ; end  ;

BLAISE PASCAL MAGAZINE is proud to announce the first edition of David Dirkse’ Dirkse’s s book:

COMPUTER MATH & GAMES IN PASCAL

www.blaisepascal.eu/DavidDirkse/ComputerMath_Games.html

DAVID DIRKSE’s

COMPUTER MATH & GAMES IN PASCAL A book printed in full color, col or, sewn back bound with a hard cover. Quality first. A fully indexed PDF file is included. The book contains 87 chapters , 53 projects with source code and compiled programs (exe). All of these projects you can download at our special website www.blaisepascal.eu The book is highly educational and suitabl e for beginner beginners s as well as for professionals. Play board games, solve puzzles, operate a vintage mechanical calculator, Produce 3-dimensional computer art, generate lists of prime numbers, expl ore and draw any mathematical function. Solve systems of equations, equatio ns, calculate calcula te the area of complex polygons. Draw lines, circles and ellipses. Resize, rotate, compress digital images. Design your own font, generate and reduce Truth Tables from Boolean algebra. And more important: understand underst and how it all works! For the games, winning strategies are explained. For puzzles the search algorithm. For all projects: the math behind is thoroughly discussed. The Delphi 3 – 7 (or later) source code is avai lable together with full explanation. Most of the projects can be done with FPC Lazarus as well. Pascal is the most educative, educative , easy to learn and only language available for several operating systems like Windows, Linux, Mac and Android. It is a great programming language…

OVERVIEW OF DELPHI TO DELPHI HISTORY

DELPHI XE8

On February 8, 2006 Borland announced Borland announced that it was looking for a buyer for its IDE and database line of products, including Delphi, to concentrate on its ALM line. On November 14, 2006 Borland transferred the development tools group to an independent subsidiary company named CodeGear CodeGear,, instead of selling it. Borland sold CodeGear to Embarcadero Technologies in 2008. Embarcadero retained the CodeGear division created by Borland to identify its tool and database offerings, but identified its own database tools under the DatabaseGear name.

Embarcadero Technologies in 2008. Codegear Delphi 2007. DELPHI 7 released in August 2002

DELPHI released February 14, 1995

The roots of Turbo Pascal v1.0 started in Denmark. Denmark. The first step, step, in 1981, was the Blue Label Software Pascal Compiler - BLS Pascal Compiler v1.2, copyright 1981 by Poly-Data microcenter ApS, Strandboulvarden Strandboulv arden 63, DK 2100 Copenhagen - written by Anders  for the NASCOM kit computer. Hejlsberg for Hejlsberg

Turbo Pascal Developer(s)) Anders Hejlsberg while Developer(s working at Borland Operating system CP/M, CP/M-86, DOS, Windows 3.x, Macintosh Platform 8080/Z80, 8085, x86

Lisa - Pascal

was a Pascal implementation for the Apple Lisa workstation. It was an extension of the earlier Apple Pascal for Apple II machines, but generated object code for 68000 processors that had to be linked against the required libraries in the Lisa OS workshop. Lisa Pascal laid the foundation for the development of Clascal and Mac Pascal the first implementations of Object Pascal.

Windows

Charles Babbage - mathematician

Niklaus Wirth

conceived of the first programmable computer in the 1830s

born February 15, 1934 He is a Swiss computer scientist, best known for designing several programming languages, including Pascal, and for pioneering several classic topics in software engineering.

Babbage never built his Difference Engine - a mechanical calculator with thousands of parts because of cost overruns and political disagreements, but the inventor passed on plans for plans for its completion, and in 1991, the Science Museum in London actually built it (the printing component was finished in 2000). As suspected, it actually works. Blaise Pascal (19 June 1623 – 19 August 1662) was a French mathematician, physicist, inventor, writer and Christian philosopher. philosopher. creates the first calculators Blaise Pascal starts to gamble - result first s tatistics

Discovery of America by Columbus Columbus led his three ships - the Nina, the Pinta and the Santa Maria out of the Spanish port of Palos on August 3, 1492. Discovery of Amerca by the Vikings 990 - 1050 Building of Spain 912 and Portugal 800 Building of France 58–52 BC

Decay of the Roman Empire 500 Building of Europe

Roman Empire 700 BC

Archimedes Mathematician Archimedes of Syracuse was an Ancient Greek mathematician, physicist, engineer engineer,, inventor, and astronomer. He is regarded as one of the leading scientists in classical antiquity. Wikipedia Born: 287 - 212 BC, Syracuse, Italy Plato in Classical Attic; 428/427 or 424/423 – 348/347 BC) was a philosopher, as well as mathematician, in Classical Greece. Euclid Mathematician Born Mid-4th century BC - 3rd century BC Residence Alexandria, Hellenistic Egypt Fields Mathematics Known for Euclidean geometry / Euclid's Elements Euclidean algorithm

IN THIS ISSUE (43)

Pythagoras Philosopher Pythagoras of Samos was an Ionian Greek philosopher philosopher,, mathematician, and founder of the religious movement called Pythagoreanism. Born: 571 - 495 BC,

Thales Philosopher Thales Philosopher Thales of Miletus was a pre-Socratic Greek philosopher from Miletus in Asia Minor and one of the Seven Sages of Greece. Many, most notably Aristotle, regard him as the first philosopher in the Greek tradition. Born: 624 BC - 546 DELPHI The cult of Apollo at Delphi probably dates back to the 700s B . C .,

Difference Engine No. 1, portion,1832

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

Babbage Difference Engine No. 2

EUCLIDES Euclid (300 BC), sometimes called Euclid of Alexandria to distinguish him from Euclid of Megara, was a Greek mathematician, often referred to as the "Father of Geometry". He was active in Alexandria during the reign of Ptolemy I (323–283 BC). His Elements is one of the most influential works in the history of mathematics, serving as the main textbook for teaching mathematics (especially geometry) from the time of  its publication until the late 19th or early 20th century. In the Elements, Euclid deduced the principles of what is now called Euclidean geometry from a small set of axioms. Euclid also wrote works on perspective, conic sections, spherical geometry, number theory and rigor. rigor.

Very few original references to Euclid survive, so little is known about his life. The date , place and circumstances of both his birth and death are unknown and may only be estimated roughly relative to other figures mentioned alongside him. He is rarely mentioned by name by other Greek mathematicians from Archimedes onward, who usually call him "the author of Elements".The few historical references to Euclid were written centuries after he lived, by Proclus c. 450 AD and Pappus of Alexandria c. 320 AD Proclus introduces Euclid only briefly in his Commentary on the Elements. According to Proclus, Euclid belonged to Plato's "persuasion" and brought together the Elements, drawing on prior work by several pupils of Plato. Proclus believes that Euclid is not much younger than these, and that he must have lived during the time of Ptolemy I because he was mentioned by Archimedes (287–212 BC). Although the apparent citation of Euclid by Archimedes has been  judg ed to be an a n interpol inte rpol atio n by later lat er editors edi tors o f his works, it is still believed that Euclid wrote his works before those of Archimedes. Proclus later retells a story that, when Ptolemy I asked if there was a shorter path to learning geometry than Euclid's Elements, "Euclid replied there is no royal road to geometry. In the only other key reference to Euclid, Pappus briefly mentioned in the fourth century that Apollonius "spent a very long time with the pupils of Euclid at Alexandria 247–222 BC.

Issue Nr 6 2015 BLAISE PASCAL MAGAZINE

Because the lack of biographical information is unusual for the period (extensive biographies are available for most significant Greek mathematicians for several centuries before and after Euclid), some researchers have proposed that Euclid was not, in fact, a historical character and that his works were written by a team of mathematicians who took the name Euclid from the historical character Euclid of Megara.

Euclidean geometry is a mathematical system attributed to the Alexandrian Greek mathematician Euclid, which he described in his textbook on geometry: the Elements. Euclid's method consists in assuming a small set of intuitively appealing axioms, and deducing many other propositions (theorems) from these. Although many of Euclid's results had been stated by earlier mathematicians, Euclid was the first to show how these propositions could fit into a comprehensive deductive and logical system. The Elements begins with plane geometry, still taught in secondary school as the first axiomatic system and the first examples of formal proof. It goes on to the solid geometry of three dimensions. Much of the Elements states results of what are now called algebra and number theory, explained in geometrical language. For more than two thousand years, the adjective "Euclidean" was unnecessary because no other sort of geometry had been conceived. Euclid's axioms seemed so intuitively obvious (with the possible exception of the parallel postulate) that any theorem proved from them was deemed true in an absolute, often metaphysical, sense. Today, however, many other self-consistent non-Euclidean geometries are known, the first ones having been discovered in the early 19th century. An implication of Albert Einstein's theory of general relativity is that physical space itself is not Euclidean, and Euclidean space is a good approximation for it only where the gravitational field is weak. Euclidean geometry is an example of synthetic geometry, in that it proceeds logically from axioms to propositions without the use of coordinates. This is in contrast to analytic geometry, which uses coordinates.

7

AN AGE PUZZLE PAGE 1/4 BY DAVID DIRKSE 

The solutions are displayed in a paintbox, see picture. We notice columns for the solution number, the year of birth, the age and the answer of the question “anniversary passed?”. Pressing the search button starts the search process. Also pressing the return key  after the current year starts the search. The text on the form is placed in Tlabel components.

On new year of the year 1997 mr. Black, a math teacher,, meets his form er student White. W hite teacher remembers Black’s fascination for number s and greets him with: “my age is equal to the sum o f the digits of my year of birth”. Black thinks for a while and then a nswers:  “co ngr ngratu atu lat ion s on yo ur birth bi rth day ”.

QUESTIONS:

1. 2.

How Black may know that it is White's birthday? What is White's age?

On the bottom of the form at full width there is a statictext comp  component onent for messages. The picture below shows : “4 solutions found”.

SOLUTION

If Peter was born in 2000 and we live in the year 2015 there are two possibilities: Peter is 14 years old and his birthda birthday y still has to come or Peter 15 years old and his birthday is passed. The solution may be found by checking all possible years and calculating the sum of the birthyear digits. Test for digitsum digits um = current year – birth year ...(1 if anniversary still has to come) This means a lot of work, so better we write a program to do the job.

×

THE PROGRAM

There may be more solutions. We choose to calculate them all and store them in a list. Thereafter the solutions are displayed on the screen. For a solution we define the data type: Tsolution  = record  birt bi rthy hyea ear r : wo word rd ; age : byte ; birth bi rthda daypa ypasse ssed d : boo boolea lean n;

; end 

And these global variables: : word ; solutions : array[1..maxsolution ] of Tsolution ; solu so luti tion onNr Nr : byte byte ;

 var thisyear

Thisyear comes from a TEdit component Thisyear comes (“this year”) where the current year was typed.  is an array[1..maxsolution] array[1..maxsolution] of type Solutions is Solutions TSolution.

SolutionNr  is the number of stored solutions. SolutionNr is This value is 0 if no solution exists.  Ma xs ol ut io n is a constant set at 20.

8

There are three reasons to make a function or a procedure. First is the case of common code that is needed at multiple places of the main program. This reduces the total code. The second reason is clearity. We place specific code apart for readability. For this reason we made a function to sum the birthyear digits.

Issue Nr 6 2015 BLAISE PASCAL MAGAZINE

AN AGE PUZZLE PAGE 2/4 MaxSolution is a constant set to 20, the space in

Third is to concentr concentrate ate specif specific ic operation operationss for maintainability. If the calculation of an area is performed by one function, in case of a change only one place in the program needs to be changed.

the solutions array. Which saves typing. Otherwise we had to add solutions[solutionNr]. before birthyear, age. Now this is done by Delphi.

umd dig igi its(ye yea ar : wo word rd ) : byte ; function sum  var s : string; i : byte ;

 begin s := int ntt tos ost tr (yea ear r ); result := 0; ] )-ord ('0'); for i := 1 to length (s ) do result := result +ord (s [i ])

; end 

The procedure ShowSolutions:

 procedure showSolutions ;

 //display solutions in paintbox1

Ord('0') is 48, the ASCII code of digit 0. So ord('8') – ord('0') = 8. Without -ord('0 -ord('0') ') we would get 56.

 var i,n : byte ; s : string ;

THE SEARCH PROCESS

 begin

x,y : word ;

In procedure searchBrtClick, called by the search clearpaintbox ; with form1.PaintBox1 .Canvas do button, we notice following local variables:  begin

 var  va r

brush brus h .st styl yle e := bs bsCl Clea ear r; font fo nt.Co Colo lor r := fo font ntco colo lor r; font fo nt.Na Name me := fo font ntna name me ; font fo nt.He Heig ight ht := fo font nthe heig ight ht ; for n := 1 to solutionNr do solu luti tion onsp sper erdi disp spla lay y then if n = >=1 10) AN AND (ID (ID
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF