Pascal – Classes

July 5, 2019

You have seen that Pascal Objects exhibit some characteristics of object-oriented paradigm. They implement encapsulation, data hiding and inheritance, but they also have limitations. For example, Pascal Objects do not take part in polymorphism. So […]

Pascal – Object Oriented

July 5, 2019

We can imagine our universe made of different objects like sun, earth, moon, etc. Similarly, we can imagine our car made of different objects like wheel, steering, gear, etc. Same way, there are object-oriented programming […]

Pascal – Date and Time

July 5, 2019

Most of the softwares you write need implementing some form of date functions returning current date and time. Dates are so much part of everyday life that it becomes easy to work with them without […]

Pascal – Units

July 5, 2019

A Pascal program can consist of modules called units. A unit might consist of some code blocks, which in turn are made up of variables and type declarations, statements, procedures, etc. There are many built-in […]

Pascal – Memory Management

July 5, 2019

This chapter explains dynamic memory management in Pascal. Pascal programming language provides several functions for memory allocation and management. Allocating Memory Dynamically While doing programming, if you are aware about the size of an array, […]

Pascal – File Handling

July 5, 2019

Pascal treats a file as a sequence of components, which must be of uniform type. A file’s type is determined by the type of the components. File data type is defined as − type file-name […]

Pascal – Sets

July 5, 2019

A set is a collection of elements of same type. Pascal allows defining the set data type. The elements in a set are called its members. In mathematics, sets are represented by enclosing the members […]

Pascal – Variants

July 5, 2019

Pascal supports a unique type of storage named variants. You can assign any simple type of values in a variant variable. The type of a value stored in a variant is only determined at runtime. […]

Pascal – Records

July 5, 2019

Pascal arrays allow you to define type of variables that can hold several data items of the same kind but a record is another user-defined data type available in Pascal which allows you to combine […]

Pascal – Pointers

July 5, 2019

Pointers in Pascal are easy and fun to learn. Some Pascal programming tasks are performed more easily with pointers, and other tasks, such as dynamic memory allocation, cannot be performed without using pointers. So it […]

Pascal – Arrays

July 5, 2019

Pascal programming language provides a data structure called the array, which can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it […]

Pascal – Booleans

July 5, 2019

Pascal provides data type Boolean that enables the programmers to define, store and manipulate logical entities, such as constants, variables, functions and expressions, etc. Boolean values are basically integer type. Boolean type variables have two […]

Pascal – Strings

July 5, 2019

The string in Pascal is actually a sequence of characters with an optional size specification. The characters could be numeric, letters, blank, special characters or a combination of all. Extended Pascal provides numerous types of […]

Pascal – Variable Scope

July 5, 2019

A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable cannot be accessed. There are three places, where variables can be declared […]

Pascal – Procedures

July 5, 2019

Procedures are subprograms that, instead of returning a single value, allow to obtain a group of results. Defining a Procedure In Pascal, a procedure is defined using the procedure keyword. The general form of a procedure definition […]

Pascal – Functions

July 5, 2019

Subprograms A subprogram is a program unit/module that performs a particular task. These subprograms are combined to form larger programs. This is basically called the ‘Modular design.’ A subprogram can be invoked by a subprogram/program, […]

Pascal – Loops

July 5, 2019

There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by […]

Pascal – Decision Making

July 5, 2019

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to […]

Pascal – Operators

July 5, 2019

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Pascal allows the following types of operators − Arithmetic operators Relational operators Boolean operators Bit operators Set operators String […]

Pascal – Constants

July 5, 2019

A constant is an entity that remains unchanged during program execution. Pascal allows only constants of the following types to be declared − Ordinal types Set types Pointer types (but the only allowed value is […]

Pascal – Data Types

July 5, 2019

Data types of an entity indicates the meaning, constraints, possible values, operations, functions and mode of storage associated with it. Integer, real, Boolean and character types are referred as standard data types. Data types can […]

Pascal – Basic Syntax

July 5, 2019

You have seen a basic structure of pascal program, so it will be easy to understand other basic building blocks of the pascal programming language. Variables A variable definition is put in a block beginning […]

Pascal – Program Structures

July 5, 2019

Before we study basic building blocks of the Pascal programming language, let us look a bare minimum Pascal program structure so that we can take it as a reference in upcoming chapters. Pascal Program Structure […]

Pascal – Environment Set Up

July 5, 2019

There are several Pascal compilers and interpreters available for general use. Among these are − Turbo Pascal − provides an IDE and compiler for running Pascal programs on CP/M, CP/M-86, DOS, Windows and Macintosh. Delphi − provides […]

Pascal – Overview

July 5, 2019

Pascal is a general-purpose, high-level language that was originally developed by Niklaus Wirth in the early 1970s. It was developed for teaching programming as a systematic discipline and to develop reliable and efficient programs. Pascal […]

Pascal Tutorial

July 5, 2019

Pascal is a procedural programming language, designed in 1968 and published in 1970 by Niklaus Wirth and named in honour of the French mathematician and philosopher Blaise Pascal. Pascal runs on a variety of platforms, […]

Get the name of the day today!

June 22, 2019

Here is an example of what the function returns: ‘The day today is ‘ + daytoday+’.’ Returns on a monday: The day today is Monday. Here is the function: function daytoday: string; begin Result:=”; {Can […]

Better moving form

June 22, 2019

unit Unit1; interface uses   Windows,   Messages,   Forms; type   TForm1 = class(TForm)   protected     procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;   end; var   Form1: TForm1; implementation {$R *.DFM} procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest); begin   // Call default procedure   inherited; […]

Change String To Proper Case

June 22, 2019

NOTE:Make sure to add “StrUtils” to your Uses section function properCase(sBuffer: string):string; var iLen, iIndex: integer; begin iLen := Length(sBuffer); sBuffer:= Uppercase(MidStr(sBuffer, 1, 1)) + Lowercase(MidStr(sBuffer,2, iLen)); for iIndex := 0 to iLen do begin […]

Delphi TextFile tutorial for beginners

June 22, 2019

Right. Well, as I explained in the purpose section, this file is meant for beginners who want to learn about text file management and routines, so, if you’re an experienced Delphi programmer, you might just […]

Understanding the Basics of Delphi Programming

June 22, 2019

Beginner developers eager to master the Delphi programming language should already be familiar with the basics of Microsoft Windows. Learning Delphi is easiest if you approach it from a guided, tutorial-based frame of reference. Foundational Concepts Get started […]

get different background color of DBGrid for odd and even rows (2)?

March 3, 2019

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //source for main form : //… uses // … Grids, DBGrids, db //… procedure artgrid(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); //… implementation //… procedure TForm1.artgrid(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if ((Sender as tdbgrid).DataSource.DataSet.RecNo mod 2) = 0 then (Sender as tdbgrid).Canvas.Brush.Color := clblue; //or any color (Sender as tdbgrid).DefaultDrawColumnCell(rect, datacol, column, state); end; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // for all DrawColumnCell event of DBGrid in any Form (here “Form2”): procedure TForm2.DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin Form1.artgrid(Sender, Rect, DataCol, Column, State); end;

get different background color of DBGrid for odd and even rows

March 3, 2019

{ Um in einem DBGrid die Übersicht zu behalten, ist es sehr angenehm, die Zeile abwechselnd einzufärben. Folgender Code soll Euch die näher bringen. Viel Erfolg beim Programmieren! Malte } procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var test1: Real; RowNo: Integer; begin with (Sender as TDBGrid) do begin if (gdSelected in State) then begin // Farbe für die Zelle mit dem Focus // color of the focused row Canvas.Brush.Color := clblue; end else begin // Zeile erfahren // get the actual row number rowno := Query1.RecNo; // gerade und ungerade Zeilen ermitteln // odd or even ? test1 := (RowNo / 2) – trunc(RowNo / 2); // Zeile gerade… // If it’s an even one… if test1 = 0 then begin farbe := clWhite […]

create an Access Database From Delphi

March 3, 2019

uses ComObj; procedure TForm1.Button1Click(Sender: TObject); var AccessApp: Variant; begin AccessApp := CreateOleObject(‘Access.Application’); AccessApp.NewCurrentDatabase(‘c:\111.mdb’); AccessApp := Unassigned; end;

create a table including an AutoInc field (ADO/MSSQL)?

March 3, 2019

// Erzeugt eine Tabelle mit dem Namen MYTABLENAME, mit den Spalten ID, // MYTEXT1, MYTEXT2. // (Der Name der ID Spalte kann natürlich frei gewählt werden.) // ID ist der Primärschlüssel der Tabelle. Er ist ein Integer, der sich // automatisch für jede Zeile // der Tabelle erhöht. ID wird nie doppelt vorkommen. // MYTEXT1 und 2 sind vom Typ String. // Ich verwende die ADOConnection um mit Jet 4.0 auf eine Access- // datenbank (*.mdb) zuzugreifen. // Der Syntax ist MSSQL, wenn ihr das für PHP oder so verwenden wollt, // muss man das ein bissel umformulieren 😉 // Creates a Table called MYTABLENAME with a unique identifier called // “ID”. ID increases with every new row automatically. MYTEXT1 and 2 // are Strings. Name the colums as you want to. // I used the ADOConnection to access a MS-Access Database (*.mdb) // via Jet 4.0. // The Syntax is MSSQL, you have to transform it to use it in PHP or so. uses AdoDB; var q: TAdoQuery; db: TAdoConnection; begin // Initialize db here q := TADOQuery.Create(nil); q.Connection := db; q.Close; q.SQL.Clear; q.SQL.Add(‘Create Table MYTABLENAME (ID COUNTER PRIMARY KEY, MYTEXT1 String, MYTEXT2 String);’); q.Prepared := True; try q.ExecSQL; except end; q.Free; end;

1 2