Visual Basic 6.0
Private Type SystemInfo CPU As Variant Memory As Long VideoColors As Integer DiskDrives() As String ' Dynamic array CDDrives(5) As String ' Fixed-size array Cost As Currency PurchaseDate As Variant temp$ ' This fails, must use As String tempStr As String End Type dim myVariable as SystemInfo Dim AllSystems(100) As SystemInfo myVarialbe.CPU = "486" tempVar = myVarialbe.CPU myVariable.temp2$ = "whatever" ' The dollar sign is ok here and refers ' to the same variable as omitting it ReDim myVariable.DiskDrives(5) ' Must set size before using ' The help does not say if the size of dynamic arrays ' is set once for all instances or once for each instance AllSystems(5).DiskDrives(2) = "100M SCSI"When using Enumerated data types, the command to list the possible options shows only those in the enumerated type definition.
type TForm1 = class(TForm) UIEdit: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; TMyRecord = record a: Integer; b: string; end;In a set, each bit represents a separate value. Up to 256 bits (32 bytes) are allowed. Each element of the set is represented by an 8-bit integer. Individual bits can be set and cleared, as well as groups of bits. (To find this in the Delphi 5 help, search for Memory management and step forward until Set types is displayed.)
type TMySet = [1, 2, 3]; TMySetVar = set of TMySet; TMySetVar = set of [1, 2, 3]; // Same as Previous 2 lines var MySet: set of 'a'..'z'; // from Delphi help on "sets" ... MySet := ['a','b','c']; // Set 3 of 26 possible bits if 'a' in MySet then ... // Test if a bit is set { do something } ; Include (MySet, 'd'); // equivalent to MySet := MySet + ['d'] but more efficient Exclude (MySet, 'd'); // equivalent to MySet := MySet - ['d'] but more efficientEnumerated - an ordered set of values referenced by identifiers
type TSuit = (tsClub, tsDiamond, tsHeart, tsSpade); var xx : TSuit; xx := tsClub;When using Ctrl-Space to list the possible options, only those in the enumerated type are displayed.
Warning: If you place the cursor on enum and press F1, the following IDL syntax is provided. This syntax can not be used in a Delphi unit (*.pas file).
typedef enum {Clemens=21, Palmer=22, Ryan=34} pitchers;
typedef struct { char a; short b; long c; } tempStruct; tempStruct temp; // This allocates space on the stack temp.a = 'x'; temp.b = 5 ; temp.c = temp.b tempStruct* tempPtr = 0; // =0 is a safety, it is not required, but should be tempPtr = new tempStruct; // This allocates space on the heap tempPtr->a = 'x'; tempPtr->b = 5 ; tempPtr->c = tempPtr->b tempStruct& tempRef = *new tempStruct; // Must initialize reference when it is created tempStruct& tempRef; // Simply allocating a Reference is Not allowed tempRef = *temp // This is ok tempRef.a = 'x'; tempRef.b = 5 ; tempRef.c = temp.bAuthor: Robert Clemenzi - clemenzi@cpcug.org