Help with a Class, Which is better a TStringList or an array of strings



Hello,

I have created the following class and was wondering if maybe using
TStringList instead of an array of string was better.

Would anyone mind looking at this class and giving any suggestions on
improving it?

Thanks Bern.



unit clsForms; { TForms component. }

interface

uses
Classes;

type
TForms = class(TObject)
private
{ Private declarations }
FFormCount: Integer;
FFormGUID: array of string;
FFormTypeGUID: array of string;
FForm: array of string;
FDataLevel: array of Integer;
FNameGUID: array of string;
function GetCount: Integer;
protected
{ Protected declarations }
function GetFormGUID(ndx: Integer): string; virtual;
procedure SetFormGUID(ndx: Integer; newValue: string); virtual;
function GetFormTypeGUID(ndx: Integer): string; virtual;
procedure SetFormTypeGUID(ndx: Integer; newValue: string);
virtual;
function GetForm(ndx: Integer): string; virtual;
procedure SetForm(ndx: Integer; newValue: string); virtual;
function GetDataLevel(ndx: Integer): Integer; virtual;
procedure SetDataLevel(ndx: Integer; newValue: Integer); virtual;
function GetNameGUID(ndx: Integer): string; virtual;
procedure SetNameGUID(ndx: Integer; newValue: string); virtual;
public
{ Public declarations }
constructor Create;
destructor Destroy; override;
function FormAdd: Integer; virtual;
procedure Clear; virtual;
function GetFormIndex(Form: string): Integer;
procedure GetForms(DrugGUID: string; var tslForms: Tstrings);
virtual;
property Count: Integer read GetCount;
property FormGUID[ndx: Integer]: string read GetFormGUID write
SetFormGUID; { Public }
property FormTypeGUID[ndx: Integer]: string read GetFormTypeGUID
write SetFormTypeGUID; { Public }
property Form[ndx: Integer]: string read GetForm write SetForm; {
Public }
property DataLevel[ndx: Integer]: Integer read GetDataLevel write
SetDataLevel; { Public }
property NameGUID[ndx: Integer]: string read GetNameGUID write
SetNameGUID; { Public }
published
{ Published properties and events }
end; { TForms }

implementation

function TForms.GetFormGUID(ndx: Integer): string;
{ Returns the value of data member FFormGUID[ndx]. }
begin
GetFormGUID := FFormGUID[ndx];
end; { GetFormGUID }

procedure TForms.SetFormGUID(ndx: Integer; newValue: string);
{ Sets data member FFormGUID[ndx] to newValue. }
begin
if FFormGUID[ndx] <> newValue then
begin
FFormGUID[ndx] := newValue;
end;
end; { SetFormGUID }

function TForms.GetFormTypeGUID(ndx: Integer): string;
{ Returns the value of data member FFormTypeGUID[ndx]. }
begin
GetFormTypeGUID := FFormTypeGUID[ndx];
end; { GetFormTypeGUID }

procedure TForms.SetFormTypeGUID(ndx: Integer; newValue: string);
{ Sets data member FFormTypeGUID[ndx] to newValue. }
begin
if FFormTypeGUID[ndx] <> newValue then
begin
FFormTypeGUID[ndx] := newValue;
end;
end; { SetFormTypeGUID }

function TForms.GetForm(ndx: Integer): string;
{ Returns the value of data member FForm[ndx]. }
begin
GetForm := FForm[ndx];
end; { GetForm }

procedure TForms.SetForm(ndx: Integer; newValue: string);
{ Sets data member FForm[ndx] to newValue. }
begin
if FForm[ndx] <> newValue then
begin
FForm[ndx] := newValue;
end;
end; { SetForm }

function TForms.GetDataLevel(ndx: Integer): Integer;
{ Returns the value of data member FDataLevel[ndx]. }
begin
GetDataLevel := FDataLevel[ndx];
end; { GetDataLevel }

procedure TForms.SetDataLevel(ndx: Integer; newValue: Integer);
{ Sets data member FDataLevel[ndx] to newValue. }
begin
if FDataLevel[ndx] <> newValue then
begin
FDataLevel[ndx] := newValue;
end;
end; { SetDataLevel }


function TForms.GetNameGUID(ndx: Integer): string;
{ Returns the value of data member FNameGUID[ndx]. }
begin
GetNameGUID := FNameGUID[ndx];
end; { GetNameGUID }

procedure TForms.SetNameGUID(ndx: Integer; newValue: string);
{ Sets data member FNameGUID[ndx] to newValue. }
begin
if FNameGUID[ndx] <> newValue then
begin
FNameGUID[ndx] := newValue;
end;
end; { SetNameGUID }

function TForms.FormAdd: Integer; { public }
var
intNewCount: integer;
begin
//Increase all the propertie arrays by one
intNewCount := Length(FForm) + 1;

setlength(FFormGUID, intNewCount);
setlength(FFormTypeGUID, intNewCount);
setlength(FForm, intNewCount);
setlength(FDataLevel, intNewCount);
setlength(FNameGUID, intNewCount);

Result := IntNewCount - 1;

end; { FormAdd }

procedure TForms.Clear;
var
intLoop: Integer;
begin
setlength(FFormGUID, 0);
setlength(FFormTypeGUID, 0);
setlength(FForm, 0);
setlength(FDataLevel, 0);
setlength(FNameGUID, 0);
FFormCount := 0;
end; { FromClear }

procedure TForms.GetForms(DrugGUID: string; var tslForms: Tstrings); {
public }
var
intLoop: Integer;
begin
for intLoop := 0 to FFormCount do
if NameGUID[intloop] = DrugGUID then
tslForms.Add(Form[intloop] + '=' + FormGUID[intloop]);
end; { GetForms }

destructor TForms.Destroy;
begin
Clear;
{ Free member variables: }
inherited Destroy;
end; { Destroy }

constructor TForms.Create;
{ Creates an object of type TForms, and initializes properties. }
begin
inherited Create;
FFormCount := 0;
{ Create property fields (that are objects): }
end; { Create }

function TForms.GetCount: Integer;
begin
Result := high(FForm);
end;

function TForms.GetFormIndex(Form: string): Integer;
var
intloop: Integer;
begin
Result := -1;
for intloop := 0 to Self.Count do
begin
if Form[intloop] = Form then
begin
Result := intloop;
exit
end;

end; // for
end;

initialization
finalization
end.

--

.



Relevant Pages

  • Re: Help with a Class, Which is better a TStringList or an array of strings
    ... > FFormTypeGUID: array of string; ... {Returns the value of data member FFormGUID. ... intLoop: Integer; ...
    (borland.public.delphi.non-technical)
  • Re: Help with a Class, Which is better a TStringList or an arrayof strings
    ... case forms are actually string like, paper, check, electronic... ... FFormTypeGUID: array of string; ... {Returns the value of data member FFormGUID. ... intLoop: Integer; ...
    (borland.public.delphi.non-technical)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • Re: Array Type Mismatch
    ... Dim resultAs String ... I am still somewhat confused as to why nothing is stored in the array. ... Public Function TextBoxGetLine(....arguments... ...
    (microsoft.public.access.formscoding)