Custom Types

Parent Previous Next

Custom Types.

New custom types can be created as:

Classes and arrays have some commonalities:

The compiler handles classes and arrays as custom types, and both have standard functions accessible in an x.y format. The many standard functions are described in detail on their respective pages - e.g. with the Class.New and Array.New as the most noticeable.

Classes and arrays provide the means for creating powerful source code programming. Here is an appetizer:

//We create 2 classes TFile and TDirectory to contain a tree of folders and files.

//NB! Using the T prefix on class names is a matter of taste. Do it as you please.

Class TFile


 Public String   Name;

 Public Integer  Size;

 Public Datetime LastModified;


Class TDirectory


 Public String     Path;          //Current folder.

 Public TDirectory Directories[]; //Array of child folders.

 Public TFile      Files[];       //Array of child files.

 Public Function Initialize()


   Directories[].New(); //Instantiate the

   Files[].New();       //two arrays.


 Public Function AddDirectory(String dirPath) : Integer


   TDirectory  directory.New().Initialize();

   directory.Path := dirPath;


   Return Directories[].Count();


 Public Function AddFile(String name; Integer size; Datetime lastModified) : Integer


   TFile  file.New().Name := name;

   file.Size := size;

   file.LastModified := lastModified;

   Return Files[].Add(file).Count();



If this example raises some questions - don't worry - the next chapters describe the details of the class and array types.