/free-pascal-snippets

This repository contains Free Pascal code snippets that I've put together while learning.

Primary LanguagePascalMIT LicenseMIT


Logo

Free Pascal Snippets

A collection of Free Pascal snippets that I put together while learning Object Pascal.
This repo is part of my study note — Free Pascal and Lazarus Cookbook.
Explore the docs »

Explore Contents · Read Free Pascal and Lazarus Cookbook · View Cookbook repo

About The Project

Demo Screen 1

This repository contains a collection of Free Pascal code snippets (work in progress) that I put togehter while studying Object Pascal with the Lazarus IDE and the Free Pascal Compiler (FPC).

It is a part of the Free Pascal and Lazarus Cookbook project.

(back to top)

Contents

The source code is organized into the following categories:

Basic Concepts

  • HelloWorld/ - The starting point; a 'Hello World' program
  • Variables/ - Examples of setting up variables in Free Pascal
  • Numbers/ - Examples of using numbers
  • Strings/ - Examples of using strings
  • Arrays/ - Examples of creating arrays
  • Lists/ - Examples of building lists
  • Loops/ - Examples of loops
  • FuncProc/ - Example of creating routines (functions and procedures)

Intermediate Features

  • Class/ - Examples of composing classes
  • Records/ - Examples of composing records
  • Interfaces/ - Examples on using Interfaces
  • Generics/ - Example on using Generics
  • AnonymousFunctions/ - Examples of anonymous functions
  • FunctionReferences/ - Snippets on Function References (requires trunk)
  • Threading/ - Examples of setting up threads
  • Immutability/ - A note on setting variables immutable
  • Subrange/ - Examples of using the subrange type

File & I/O Operations

  • ConsoleInputOutput/ - Simple examples on console IO
  • CommandLineArguments/ - Examples on parsing command line arguments and options
  • DirsPathsFiles/ - Examples of composing paths
  • FileHandling/ - Snippet on file handling; reading and writing
  • FileHandling_II/ - Snippet on file handling of other file formats; CSV

Advanced Topics

  • DateTime/ - Snippets about date manipulation
  • Debugging/ - Examples of debugging
  • Regex/ - Examples of utilizing Regex
  • Networking/ - Examples of using networking
  • CodeStructure/ - Examples on structuring Pascal source files

Libraries & Frameworks

  • LGenerics/ - Examples of using LGenerics
  • Mormot2/ - Examples of using mormot2
  • NumLib/ - Examples of using Numlib
  • Lazarus/ - A GUI of 'Hello World' in Lazarus IDE

Compilation Output

When you compile any project, the executable output will be placed in the top-level bin/ folder of the repository.

Why? This keeps the compiled binaries separate from the source code and makes it easier for me to manage multiple examples.

Getting Started

Prerequisites

  1. Interest in Object Pascal.
  2. Install both the Free Pascal Compiler (FPC) and Lazarus IDE. You can use the Lazarus IDE installer or fpcupdeluxe to install both.

Installation

None. Just download or git clone the repo to your local drive.

(back to top)

Usage

Using Lazarus IDE

  1. Launch your Lazarus IDE.
  2. Top bar menu, go to Projects - Open Project ....
  3. Navigate to the snippet folder you'd like to see, and open the .lpi file.

Using your favourite text editor

  1. Navigate to an example folder.
  2. Open the .lpr file. This is the program source code.

License

Distributed under the MIT License. See LICENSE.md for more information.

(back to top)

Contact

Find me at these places:

Project Link: https://github.com/ikelaiah/free-pascal-snippets

(back to top)

Acknowledgments

(back to top)