Delphi Prism Tech Articles

These Articles are contributed by you (our online community members). They are organized by our knowledge base topics. Specifically, by the Prism sub-topics.

22 Delphi Prism Articles

Group: Delphi Prism

Topic: Delphi Prism

In Prism, a string can be nil (unassigned), assigned an empty string (""), or assigned a value.  Therefore, to check if a string is empty, you have to check against both nil and (""). Alternatively, you can check the length of the string or use String.IsNullOrEmpty.

Topic: Tool Basics

Can I share code between a Delphi and a Dephi Prism project? I want to have a single source Win32 and .Net application.

Topic: Language Basics

Same as in Delphi for Win32 but Prism also supports inline variable declaration.

In Prism, everything is within a class (just like with C#, VB.Net, and Java). So you create class methods using the method keyword. Alternatively, you can use procedure or function if you want the compiler to enforce returning or not returning a value.

Unlike Delphi, Prism performs implicit casting. To concatenate two strings, a string to an integer, or a string to a floating point number, use the + operator. For example, to convert a floating point number to a string just concatenate an empty string to the number as in "" + 3.2.

The Prism unary operators are:


Topic: Language Details

Like Delphi, Prism supports overloading. However, Prism supports implicit overloading (no need for an overload keyword).

Topic: OOP

Prism supports abstract class members and abstract classes using the abstract keyword. An abstract class is a class with one or more abstract members and you cannot instantiate an abstract class. However, you can have additional implemented methods and properties. An abstract member is either a method (method, procedure, or function), a property, or an event in an abstract class. You can add abstract members ONLY to abstract classes using the abstract keyword. Alternatively, you can use the empty keyword in place of abstract if you wish to instantiate the abstract class.

Declare your class in the Interface section. Then implement the class in the Implementation section. To create an object instance, use the New keyword. Optionally, you can use Create for backword compatibility with Delphi if you turn it on in the compatibility options. Since Prism does have a garbage collector, you do not have to free the object. If you need to free either unmanaged resources or resources where "timing" is important, implement IDisposable and take control of freeing the object yourself using Dispose.

Prism uses unnamed constructor methods for constructors. Prism also supports a Create constructor method for backward compatibility with Delphi for Win32.

Unlike Delphi, Delphi Prism uses the .Net garbage collector to free managed object instances. Prism does not have nor need a true destructor.

In .Net, a finalizer is used to free non-managed objects such as a file or network resource. Because you don't know when the garbage collector will call your finalizer, Microsoft recommends you implement the IDisposable interface for non-managed resources and call it's Dispose() method at the appropriate time.

With Prism, you use the Interface keyword to define an interface and then you include one or more interfaces where you specify the single class inheritance (separated by commas).

In Prism you can set the visibility of a member field to any visibility: private, protected, public, assembly and protected or assembly or protected. Prism supports the readonly modifier for member fields which is handy for constant like data. In this case, I chose not to preface my read-only member field with "F" so it's usage is just like a read-only property. Prism also support the class modifier (static data) for member fields. Delphi developers should notice the use of := to initialize a member field (in Delphi you use an =).

Prism supports a full suite of member modifiers. Prism virtuality modifiers are virtual, override, final, and reintroduce. Prism general modifiers are abstract, empty, async, external, locked, unsafe, implements, and iterator. Not all member types support all member modifiers. For example, member fields support only readonly and implements.

Same as Delphi. In Prism, you specify a virtual method with the virtual keyword in a parent class and replace it in a descendant class using the override keyword. Call Inherited in the descendant method to execute the code in the parent method.

Prism supports both partial classes and partial methods using the keyword partial. A partial method is an empty method defined in a partial class.

Topic: Delphi for .Net Archive

use of Sender under Delphi for .NET

Some initial questions and answers we had as we first approached building ASP.NET applications using Delphi 2006

Tips on deploying ASP.NET pages written with Delphi for .NET 2006

Delphi 8 fix for Required package Borland$ not found caused by the .Net Framework service pack 1 update.

Some initial tips on the road to using Delphi to program ASP.NET web pages.

Private and public variables on objects may not behave the way you'd expect, causing you to have to declare them more globally. For service: 916-726-5675
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 10/18/2021