Delphi Language Guide

Total Page:16

File Type:pdf, Size:1020Kb

Delphi Language Guide Product Documentation Delphi Language Guide Version 10.3 Rio Latest version is found on online docwiki.embarcadero.com/RADStudio/en/Delphi_Language_Guide_Index © 2019 Embarcadero Technologies, Inc. Embarcadero, the Embarcadero Technologies logos, and all other Embarcadero Technologies product or service names are trademarks or registered trademarks of Embarcadero Technologies, Inc. All other trademarks are property of their respective owners. Embarcadero tools are built for elite developers who build and maintain the world’s most critical applications. Our customers choose Embarcadero because we are the champion of developers, and we help them build more secure and scalable enterprise applications faster than any other tools on the market. In fact, ninety of the Fortune 100 and an active community of more than three million users worldwide have relied on Embarcadero's award-winning products for over 30 years. If you’re trying to build a business-critical application in a demanding vertical, Embarcadero is for you. If you’re looking to write steadfast code quickly that will pass stringent code reviews faster than any other, Embarcadero is for you. We’re here to support elite developers who understand the scalability and stability of C++ and Delphi and depend on the decades of innovation those languages bring to development. We invite you to try our products for free and see for yourself. www.embarcadero.com/products/rad-studio/start-for-free Embarcadero is an Idera, Inc. company. Idera, Inc. is the parent company of global B2B software productivity brands whose solutions enable technical users to do more with less, faster. Idera, Inc. brands span three divisions – Database Tools, Developer Tools, and Test Management Tools – with products that are evangelized by millions of community members and more than 50,000 customers worldwide, including some of the world’s largest healthcare, financial services, retail, and technology companies. Embarcadero and Idera are online at www.embarcadero.com and www.ideracorp.com November, 2019 In support of the education of new developers, and as part of LearnDelphi.org, this document is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) creativecommons.org/licenses/by-sa/4.0/ Please link back to embarcadero.com and learndelphi.org Embarcadero Technologies 2 CONTENTS Language Overview....................................................................................................... 15 Program Organization ................................................................................................ 15 Delphi Source Files ................................................................................................... 16 Other Files Used to Build Applications .................................................................. 16 Compiler-Generated Files ...................................................................................... 17 Example Programs ...................................................................................................... 17 A Simple Console Application ............................................................................... 18 A More Complicated Example ............................................................................. 19 A VCL Application ................................................................................................... 20 Programs and Units Index .............................................................................................. 23 Topics ............................................................................................................................ 23 Programs and Units (Delphi) .......................................................................................... 24 Program Structure and Syntax .................................................................................. 24 The Program Heading ............................................................................................. 24 The Program Uses Clause ....................................................................................... 25 The Block ................................................................................................................... 25 Unit Structure and Syntax ........................................................................................... 26 The Unit Heading ..................................................................................................... 27 The Interface Section .............................................................................................. 27 The Implementation Section .................................................................................. 27 The Initialization Section .......................................................................................... 28 The Finalization Section ........................................................................................... 28 Unit References and the Uses Clause ...................................................................... 29 The Syntax of a Uses Clause ................................................................................... 29 Multiple and Indirect Unit References .................................................................. 30 Circular Unit References ......................................................................................... 31 Using Namespaces with Delphi .................................................................................... 32 Declaring Namespaces ............................................................................................. 33 Searching Namespaces ............................................................................................. 34 Namespace search order ...................................................................................... 34 A namespace search example ............................................................................ 34 Using Namespaces ..................................................................................................... 35 Fully qualified unit names ....................................................................................... 35 Multi-unit Namespaces ........................................................................................... 36 Fundamental Syntactic Elements Index ...................................................................... 37 Topics ............................................................................................................................ 37 Fundamental Syntactic Elements (Delphi) ................................................................. 38 The Delphi Character Set ........................................................................................... 38 Tokens ............................................................................................................................ 39 Special Symbols ....................................................................................................... 39 Identifiers ................................................................................................................... 40 Embarcadero Technologies 3 Reserved Words ....................................................................................................... 41 Directives ................................................................................................................... 42 Numerals ................................................................................................................... 44 Labels......................................................................................................................... 45 Character Strings ..................................................................................................... 45 Comments and Compiler Directives ........................................................................ 46 in ........................................................................................................................................ 47 Expressions (Delphi) ......................................................................................................... 48 Expressions .................................................................................................................... 48 Operators ...................................................................................................................... 49 Arithmetic Operators .............................................................................................. 49 Boolean Operators .................................................................................................. 50 Complete Versus Short-Circuit Boolean Evaluation ........................................... 51 Logical (Bitwise) Operators .................................................................................... 52 String Operators ....................................................................................................... 54 Pointer Operators .................................................................................................... 54 Set Operators ........................................................................................................... 55 Relational Operators ............................................................................................... 56 Class and Interface Operators .............................................................................
Recommended publications
  • Rapid Application Development Software | Codegear RAD Studio
    RAD Studio 2010 Product Review Guide August 2009 Corporate Headquarters EMEA Headquarters Asia-Pacific Headquarters 100 California Street, 12th Floor York House L7. 313 La Trobe Street San Francisco, California 94111 18 York Road Melbourne VIC 3000 Maidenhead, Berkshire Australia SL6 1SF, United Kingdom RAD Studio 2010 Reviewer Guide TABLE OF CONTENTS Table of Contents ............................................................................................................................ - 1 - Introduction ...................................................................................................................................... - 3 - General Overview of RAD Studio 2010 ...................................................................................... - 3 - What is New in RAD Studio 2010 ............................................................................................... - 3 - A Word on Delphi Prism ............................................................................................................. - 6 - Prerequisites ................................................................................................................................ - 7 - Minimum System Requirements ................................................................................................. - 7 - Internationalizations .................................................................................................................... - 7 - Editions ........................................................................................................................................
    [Show full text]
  • Delphi XE2 Feature Matrix
    Delphi® XE2 The fastest way to build native applications for Windows, Mac and iOS Feature Matrix Feature Architect Ultimate Enterprise Professional Starter INTEGRATED COMPILERS Enhanced in XE2! High-performance 32-bit optimizing Delphi® native code compiler 23.0 (dcc32), including High performance x86 Assembler – 32-bit inline assembler supporting the Intel® x86 instruction set (including Intel Pentium® Pro, Pentium III, X X X X X Pentium 4, Intel MMX™, SIMD, Streaming SIMD Extensions, SSE, SSE2, SSE3, SSE 4.1, SSE 4.2, AMD SSE4A and AMD® 3DNow!® New in XE2! Delphi 64-bit compiler X X X X New in XE2! Delphi OS X compiler X X X X Delphi command line compiler (dcc32.exe) X X X X Enhanced in XE2! Create 32-bit optimized Delphi native executables that can run X X X X X on both 32 and 64-bit Windows operating systems APPLICATION PLATFORMS, INTEGRATED FRAMEWORKS, DESIGNERS, SDKS AND INSTALLERS New in XE2! FireMonkey Platform for creating 32-bit Windows applications for X X X X X Windows 7, Windows Vista and XP; Server 2003 and 2008. New in XE2! FireMonkey Platform for creating 64-bit Windows applications for X X X X Windows 7, Windows Vista and XP; Server 2003 and 2008. New in XE2! FireMonkey Platform for creating OS X 10.6 and 10.7 applications X X X X New in XE2! FireMonkey Platform for creating applications for iOS 4.2 and higher X X X X New in XE2! VCL (Visual Component Library) for rapidly building 64-bit applications X X X X for Windows 7,Windows Vista and XP; Server 2003 and 2008.
    [Show full text]
  • The Delphi Language for Mobile Development
    This document is an introduction to changes in the “Mobile” version of Delphi and the new Delphi ARM compiler. The focus of this document is to highlight the language changes and techniques that can be used to port existing code and to maintain backwards compatibility. Author: Marco Cantu, Delphi Product Manager, Embarcadero Technologies (suggest updates and integrations to [email protected]). Written with very significant technical contributions by Allen Bauer and the help of many reviewers. Document Revision: 1.0 Moving Delphi to mobile ARM platforms is part of a larger evolution for the Delphi language. As such, the R&D team here at Embarcadero adopted a new architecture that will be common among all Embarcadero languages. Rather than building the compiler and all of the related tools (often indicated with the term “toolchain”) in a completely proprietary and autonomous way, we decided to leverage an existing compiler and tool chain infrastructure that has broad industry support, making it faster for us to add new platforms and operating systems in the future as market demands change. Specifically, the new generation of Delphi compilers (and also the C++Builder compilers) utilize the LLVM architecture. What is this LLVM and why does this matter? Let’s take a quick look at LLVM, and return to our main topic later. The LLVM project has its main web site with a detailed description at http://llvm.org In short, LLVM is “a collection of modular and reusable compiler and tool-chain technologies”. Despite the name (which was originally an acronym, but it is now considered as “the full name of the project”), LLVM has little to do with virtual machines.
    [Show full text]
  • C++ Builder 2010 Professional Getting Started
    C++ Builder 2010 Professional Getting started. Kjell Gunnar Bleivik: http://www.kjellbleivik.com/ October 18. 2010. Fixed broken link. Status: Most probably finished. Look at the date in case more should be added. Follow me on Twitter and join my C++ Builder group on Facebook: Twitter: http://twitter.com/kbleivik FaceBook: http://www.facebook.com/people/Kjell-Gunnar-Bleivik/1244860831 Mini network: http://www.digitalpunkt.no/ 1. Installing C++Builder 2010, the help system etc. I ordered my upgrade of Borland C++ Builder Prosessional 2010 on September 21 2009 so I could choose an additional free product. I choose Delphi PHP 2.0, since I am fairly used to PHP. In order to install C++ Builder 2010, I had to upgrade my 2009 version. I have made an 2009 and 2010 upgrade shortcut on my desktop. You should find your upgrade program: | your start menu or in | the all program category | CodeGear RAD studio 2009 | Check for updates | Program | When finished upgrading the 2009 Builder, I could run the C++ Builder 2010 Setup program. In addition, I installed the additional first three programs that I also find in the Install Folder. Look at the screendumps below, so you get it correct. • Help_Setup Program • dbpack_setup Program • boost_setup Program • Additional_Products HTML document. • ERStudio_Interbase HTML document 2. Getting started with C++ Builder 2010 Professional. If you learn to use the welcome page efficiently, that may be all you need. On the “documentation” menu, you should start with, yes “Getting started” and then “RAD Studio Help” and so on. As an example click: | Documentation | … and try to locate this http://docs.embarcadero.com/products/rad_studio/ page with Wiki pages, PDF documents, zipped code examples for download, PDF documents since C++Builder 6 (scroll down to the bottom) and CHM http://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help files.
    [Show full text]
  • Managing Java EE Performance with Embarcadero's J Optimizer Request
    Tech Notes Managing Java EE Performance with Embarcadero’s J Optimizer Request Analyzer Al F. Mannarino, Embarcadero Technologies June 2008 Corporate Headquarters EMEA Headquarters Asia-Pacific Headquarters 100 California Street, 12th Floor York House L7. 313 La Trobe Street San Francisco, California 94111 18 York Road Melbourne VIC 3000 Maidenhead, Berkshire Australia SL6 1SF, United Kingdom Managing Java EE Performance Using Embarcadero J Optimizer Request Analyzer The iterative use of performance tools throughout the development process is critical for keeping performance and reliability problems under control as well as for producing fast, scalable Java EE and Java SE applications. Java™ technology is great for accelerating time-to market, but performance and reliability risks can become a serious challenge. Because Java technology provides a higher level of abstraction, it affords developers only a limited understanding of—and control over—the way their code is executed. Embarcadero J Optimizer offers a four-pronged attack at improving Java application performance. Three of those four prongs address developer performance considerations and are focused on individual developer productivity, identifying performance risks and reliability issues, and helping developers correct problems such as memory leaks, performance bottlenecks, and multi- threading issues. Within J Optimizer there are three profiling tools which help address these areas. • Profiler—examine memory and CPU use; identify memory leaks, inefficient temporary storage issues, CPU bottlenecks, and unit test performance regressions. • Thread Debugger—identify and analyze thread contention issues, thread-starvation, excessive locking, deadlocks, and other thread related issues. • Code Coverage—identify and analyze the classes, methods and lines of code that are being executed; remove dead code, improve quality, and improve the application's footprint.
    [Show full text]
  • C++Builder XE5 Feature Matrix | Multi-Device, True Native App
    C++Builder® XE5 Multi-device, true native app development with C++ Feature Matrix Feature Architect Ultimate Enterprise Professional Starter INTEGRATED COMPILERS AND TOOLCHAINS Introduced in XE3! C++ 64-bit compiler for Windows X X X X Enhanced in XE3! C++ OS X compiler X X X X Enhanced in XE5! Embarcadero C++ Compiler 6.70 (bcc64) X X X X Enhanced in XE5! Embarcadero C++ Compiler 6.70 (bcc32) X X X X Enhanced in XE3! C++ command line toolchains for Windows X X X X X Enhanced in XE3! C++ command line toolchains for OS X (bccosx) X X X X Create 32-bit optimized native executables that can run on both 32 X X X X X and 64-bit Windows operating systems Enhanced in XE3! ANSI/ISO C++11 and 99 Standard language X X X X conformance and Boost support for 64-bit #pragma once support that allows for better compatibility with MSVC X X X X X and also acts as a header guard [[deprecated]] attribute to flag constructs as deprecated X X X X X Build C++ packages for 32-bit applications X X X X X Secure C library functions X X X X X Enhanced compiler switches for XML representation of source code X X X X X Custom evaluators for C++ Strings types X X X X X Linker error handling to improve memory management flexibility and X X X X X resolution APPLICATION PLATFORMS, INTEGRATED FRAMEWORKS, DESIGNERS AND SDKS Enhanced in XE3! FM Application Platform for creating 32-bit Windows applications for Windows 8, Windows 7, Windows Vista and X X X X X XP; Server 2008 and 2012.
    [Show full text]
  • RAD Studio, Delphi, C++Builder XE8 Feature Matrix
    RAD Studio / Delphi / C++Builder Products Feature Matrix Each feature has an indication if it is available in the Delphi (D) and/or the C++Builder (C) personality, or in the HTML5 Builder (H) tool. RAD Studio editions include all three personalities, while single product editions (Delphi and C++Builder) have only the features marked for the corresponding personality. Enterprise+ indicates Enterprise and above editions (Ultimate, Architect). Starter edition is available only for single personalities, not for RAD Studio. See also the notes description at the bottom of this page. Feature Enterprise+ Professional Starter INTEGRATED COMPILERS AND TOOLCHAINS Delphi 32-bit native code optimizing compiler (dcc32), including high performance x86 Assembler D D D Delphi 64-bit compiler (dcc64) D D Delphi command line toolchains for Windows D D D5 Delphi OS X compiler (dccosx) D D Delphi command line toolchains for Mac OS X D D Delphi iOS ARM compiler (dccios32, dcciosarm) D D1 Delphi command line toolchains for iOS D D1 Introduced in XE8! iOS 64 bit Object Pascal compiler and toolchain D D1 Delphi Android ARM compiler for Device (dccaarm) D D1 Delphi command line toolchains for Android D D1 Embarcadero C++ compiler for Win64 (bcc64) C C Embarcadero C++ compiler for Win32 (bcc32) C C C New in 10 Seattle! C++ 11 CLANG-based compiler for Win32 (bcc32c) C C C Enhanced in 10 Seattle! Upgrade to v3.3 of CLANG and LLVM for Win64 and Win32 C C C5 C++ command line toolchains for Windows C C C5 C++ OS X compiler (bccosx) C C C++ command line toolchains for
    [Show full text]
  • RAD Studio Mobile Tutorials
    Product Documentation RAD Studio Mobile Tutorials Version XE7 © 2014 Embarcadero Technologies, Inc. Embarcadero, the Embarcadero Technologies logos, and all other Embarcadero Technologies product or service names are trademarks or registered trademarks of Embarcadero Technologies, Inc. All other trademarks are property of their respective owners. Embarcadero Technologies, Inc. is a leading provider of award-winning tools for application developers and database professionals so they can design systems right, build them faster and run them better, regardless of their platform or programming language. Ninety of the Fortune 100 and an active community of more than three million users worldwide rely on Embarcadero products to increase productivity, reduce costs, simplify change management and compliance and accelerate innovation. The company's flagship tools include: Embarcadero® Change Manager™, CodeGear™ RAD Studio, DBArtisan®, Delphi®, ER/Studio®, JBuilder® and Rapid SQL®. Founded in 1993, Embarcadero is headquartered in San Francisco, with offices located around the world. Embarcadero is online at www.embarcadero.com. November, 2014 Embarcadero Technologies 2 CONTENTS Mobile Tutorials: Mobile Application Development (iOS and Android) ................... 9 Setup ................................................................................................................................. 10 Using Basic User Interface Elements ............................................................................. 10 Using Device Functionality ...........................................................................................
    [Show full text]
  • The Delphi Language for Mobile Development
    The Delphi Language for Mobile Development Marco Cantù, Delphi Product Manager Embarcadero Technologies April 2013 Americas Headquarters EMEA Headquarters Asia-Pacific Headquarters 100 California Street, 12th Floor York House L7. 313 La Trobe Street San Francisco, California 94111 18 York Road Melbourne VIC 3000 Maidenhead, Berkshire Australia SL6 1SF, United Kingdom | White Paper The Delphi Language for Mobile Development INTRODUCTION This document is an introduction to changes in the “Mobile” version of Delphi and the new Delphi ARM compiler. The focus of this document is to highlight the language changes and techniques that can be used to port existing code and to maintain backwards compatibility. Author: Marco Cantu, Delphi Product Manager, Embarcadero Technologies (suggest updates and integrations to [email protected]). Written with very significant technical contributions by Allen Bauer and the help of many reviewers. Document Revision: 1.0 1. A NEW COMPILER ARCHITECTURE Moving Delphi to mobile ARM platforms is part of a larger evolution for the Delphi language. As such, the R&D team here at Embarcadero adopted a new architecture that will be common among all Embarcadero languages. Rather than building the compiler and all of the related tools (often indicated with the term “toolchain”) in a completely proprietary and autonomous way, we decided to leverage an existing compiler and tool chain infrastructure that has broad industry support, making it faster for us to add new platforms and operating systems in the future as market demands change. Specifically, the new generation of Delphi compilers (and also the C++Builder compilers) utilize the LLVM architecture. What is this LLVM and why does this matter? Let’s take a quick look at LLVM, and return to our main topic later.
    [Show full text]
  • The Self-Explanatory Pascal Language Has Inspired Me for 30 Years. It Is A
    SUCCESS STORY HEIDISQL Ansgar Becker has been developing a lean database client using Delphi since 1999. In the beginning it was only meant for MySQL, but over the years HeidiSQL has established itself worldwide as a very popular and frequently used OpenSource tool, as have SQL Server, PostgreSQL, and SQLite. APPLICATION HeidiSQL would never have progressed HeidiSQL so fast without the new features of Delphi. DEVELOPER The diverse components of the VCL offer lean Ansgar Becker solutions for many practical purposes. – Ansgar Becker GENRE Management Client for Database ‘‘ Systems CHALLENGE • MySql, MariaDB In 1998, the author and web developer was not satisfied with the programs available • SQL Server to him at that time to manage a MySQL server. The desire arose to visualize the • PostgreSQL database structures as intuitively as possible. Due to school knowledge in Turbo • SQLite Pascal, the Delphi 3 license of the employer, and the still very young Internet, a whole world of possibilities was available to him. At the same time, Matthias’’ USED TOOLS Fichtner published his Delphi translation of the mysql.h header file. With this, the first connections to the MySQL server were established. Equipped with these Delphi, VCL prerequisites, a customized user interface had to be designed and implemented. Since then, the Delphi Form-Designer and the endless possibilities of the VCL have inspired Becker again and again to improve usability. The self-explanatory Pascal language has inspired me for 30 years. It is a high-level language with natural elements, which is very easy to learn and always a welcome change for me as a web developer.
    [Show full text]
  • RAD Studio XE5 Feature Matrix | Multi-Device, True Native
    RAD Studio XE5 Multi-device, true native app development for Android and iOS Personality: D = Delphi® C = C++Builder® Feature Matrix H = HTML5 Builder Feature Personality Architect Ultimate Enterprise Professional INTEGRATED COMPILERS AND TOOLCHAINS High-performance 32-bit optimizing Delphi® native code compiler (dcc32), including High performance x86 Assembler – 32-bit inline assembler supporting the Intel® x86 instruction set (including Intel Pentium® Pro, Pentium III, Pentium 4, Intel MMX™, SIMD, Streaming D X X X X SIMD Extensions, SSE, SSE2, SSE3, SSE 4.1, SSE 4.2, AMD SSE4A and AMD® 3DNow!® Delphi 64-bit compiler for Windows D X X X X Introduced in XE3! C++ 64-bit compiler for Windows C X X X X Enhanced in XE3! Delphi OS X compiler D X X X X Enhanced in XE3! C++ OS X compiler C X X X X Enhanced in XE5! Embarcadero C++ Compiler 6.70 (bcc64) C X X X X Enhanced in XE5! Embarcadero C++ Compiler 6.70 (bcc32) C X X X X Delphi command line toolchains for Windows (dcc32, dcc64) D X X X X Introduced in XE4! Delphi command line toolchains for iOS (dccios32, dcciosarm) D X X X X Introduced in XE4! Delphi iOS ARM Compiler and Delphi iOS Compiler for iOS Simulator D X X X X New in XE5! Delphi Android ARM compiler for Device and Emulator (dccaarm) D X X X X Enhanced in XE3! Delphi command line toolchains for OS X (dccosx) D X X X X C++ command line toolchains for Windows (bcc32, bcc64) C X X X X Enhanced in XE3! C++ command line toolchains for OS X (bccosx) C X X X X Create 32-bit optimized Delphi and C++ native executables that can run on both
    [Show full text]
  • Using New Delphi Coding Styles and Architectures a Review of the Language Features in Delphi 2009
    Tech Notes Using New Delphi Coding Styles and Architectures A Review of the Language Features in Delphi 2009 Marco Cantù December 2008 Corporate Headquarters EMEA Headquarters Asia-Pacific Headquarters 100 California Street, 12th Floor York House L7. 313 La Trobe Street San Francisco, California 94111 18 York Road Melbourne VIC 3000 Maidenhead, Berkshire Australia SL6 1SF, United Kingdom Using New Delphi Coding Architectures and Styles INTRODUCTION: THE DELPHI LANGUAGE The Delphi language, better known as Object Pascal, is a modern strong type-checked and object-oriented language, featuring single inheritance and an object reference model. In recent years, the language has been augmented with record with methods, operators overloading for records, class data, nested types, sealed classes, final methods and many other relevant features. The most surprising extension was probably the introduction of class helpers, a technique used to add new methods to an existing class or replace some of the existing methods. But in Delphi 2009 the new features added to the compiler are even more relevant. Besides the extensions to the string type to support Unicode, the last version of Delphi introduces generic data types, anonymous methods, and a number of other “minor” but very interesting features. INTRODUCING GENERICS As a first example of a generic class, I've implemented a key-value pair data structure. The first code snippet below shows the data structure as it is traditionally written, with an object used to hold the value: type TKeyValue = class
    [Show full text]