Property
This section covers the definition, syntax, specifications and serialization of Properties What is a Property property is syntactic sugar in Pascal. Externally it behaves like a field, but internally it …
Independent Software Developer Studio
Learn Object Pascal with Free Pascal. Master basic grammar, classes and cross-platform programming. Create console and desktop software with clean, easy-to-read code examples.
This section covers the definition, syntax, specifications and serialization of Properties What is a Property property is syntactic sugar in Pascal. Externally it behaves like a field, but internally it …
Pascal/FPC is Type Check, as Safe Cast, TClass(X) Unchecked Raw Cast Usage of is and as 1 is Operator: Runtime Type Detection Check whether an object instance belongs to a …
Class, Class Instance, Constructor, Destructor The example above includes TAnimal and its subclass TDog. A class is merely a type, which can be understood as a template. The class itself …
Inheritance, Virtual Methods, override, reintroduce Example of Class Inheritance Object Pascal supports inheritance and virtual methods. In the example below, TDog inherits from TAnimal: TDog is the derived class (subclass), …
Object Pascal supports classes A class is a container that holds the following members Classes can also contain other types of members, which will be covered later. Classes are a …
Expose identifiers from other units through a new unit Sometimes you need to re-export and expose identifiers from another unit within your new current unit. The end result: as long …
Similar to namespaces in C++, Java and C# Conflicts of Identifiers with Identical Names Multiple units may define types / functions / variables sharing the same name. Units placed later …
Understanding Units can reference and depend on one another. When one unit references another, the referenced unit can be declared either in the interface section or solely in the implementation …
A Unit can also contain an initialization section and a finalization section. These two blocks of code run automatically when the program starts and exits respectively. initialization: Executes when the …
Unit File Extension All unit source files use the unified .pas extension. Filenames are recommended to be all lowercase, e.g. myunit.pas. FPC supports custom extensions. Some developers use .pp for …
A Unit packages shared type declarations, functions, procedures, constants, variables and more for invocation by other units or the main program, equivalent to modules / packages in other programming languages. …
If you don’t want to print directly but concatenate any number of variables into a complete string, Pascal offers three mainstream implementation methods: Concatenation via Dedicated Conversion Functions ***ToStr + …
Console Output Write / WriteLn To print strings in Pascal, use the built-in procedures Write or WriteLn; WriteLn automatically appends a line break at the end. This is an extremely …
Four types of loops: for / while / repeat / for-in Refer to the examples below first. Modify the code file from the previous lesson, mydemo.dpr, and change its extension …
Ordinal Types as Array Subscripts Constant-length arrays Enumerations and custom range ordinal types can be used as array subscripts, allowing flexible customization of array index ranges. Example: Enums as Array …
1. Enumerated Type Pascal enums are well-encapsulated opaque types and used far more frequently in day-to-day development than enums from other programming languages. Basic Declaration Syntax Coding convention: Prefix enum …
Multi-branch Judgment with Single Expression If you need to execute different logic based on distinct values of the same expression, the case .. of .. end statement is highly suitable. …
1 Logical operators include: and, or, not, xor These operators take boolean values as operands and also return boolean results; When both operands are integers, and/or/not/xor become bitwise operators and …
Use if .. then or if .. then .. else to run corresponding code when the condition is true. Unlike C-style languages: the conditional expression in Pascal does not need …
Modify the dpr file from the previous lesson to the following content Below is the comment explanation. Non-English text may display garbled characters; you can configure the console to output …