Actually I was only saying Tmemo or TRichedit as an example.  As
this is for code I'm using the TMS EditMemo because it includes nearly
everything I need including syntax highlighting modules for Delphi, HTML,
XML...  For formatted writing, I have used the TrichEdit class before, and
its okay but personally I prefer to simply call up Word!  Note that in my
last post I mentioned that using a record instead of a TObject and a dynamic
array to keep track of them actually turned out to be a better solution for
a lot of reasons.  I just had some questions regarding the use of arrays
that I'm not sure about as I haven't had need to use many of them before.
Also, I've run into what seems to be a peculiar problem where a procedure
that measures the client-rect so that the margin ruler can be set properly
is evidently being called somewhere within my Onclose event...after the memo
is destroyed!  I get an AV on close therefore.  I'm going to try and work
that out today.  

from Robert Meek dba Tangentals Design  CCopyright 2006

"When I examine myself and my methods of thought, I come to the conclusion
that the gift of Fantasy has meant more to me then my talent for absorbing
positive knowledge!"
                                                    Albert Einstein


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Rob Kennedy
Sent: Friday, March 03, 2006 6:42 PM
To: Borland's Delphi Discussion List
Subject: Re: Objects and Lists

Robert Meek wrote:
> I've been trying to write a simple code editor that allows for
> multiple files to be opened at the same time, and using only one TMemo or
> TRichedit to do so.

Go write a program using Notepad or Wordpad, and then reconsider whether 
a TMemo or a TRichEdit is really an appropriate environment for editing 
code.

> My intention was to create an object like so:
> 
> type
> TMainObject  =  Class(TObject)
>     FName : String;
>     FFileName : String;
>     FLines : TStrings;
>     FEnc : Boolean; // for Encryption
>     FROnly : Boolean; // for ReadOnly
>     FTag : Integer; // ?
> End;  
>       As well as some simple local to the unit variables:

Make them fields of the form class that managers the files.

> Var
>     MyObj : TMainObject;
>     ObjList : TObjectList;
>     ObjCount : Integer;

TObjectList maintains its own count, you know.

> And as the editor is created or one clicked on "New", or "Open" an
> instance of MyObj would be created and added to a TObjectList so as to
keep
> track of them.  At the same time a new TAB would be added to the
tabcontrol
> so the user could move from tab to tab, with each move storing the current
> lines of the editor in the former tab's object and then loading the lines
of
> the editor from the property of the new tab's object.

So far, so good. I did the same thing a few years ago.

> In the case of a
> "New" instance all properties would be '' or False except for the FName
> which would be "Untitled", and the FTag which would equal the index of the
> ObjectList Item it is added as, and which also would equal the tabIndex of
> the Tab it belongs to..  Another var would keep track of the count from
> outside the Object.

Under what circumstances would the count from outside the object be any 
different from the count inside the object? Why keep track of the same 
information in two places?

Making the objects keep track of their own indices may get complicated. 
When you close a file, you'll need to go back and re-index all the 
remaining files. But why bother? The lost object already has an IndexOf 
method, so you can ask it what the index of any object is. Why keep 
track of the same information in two places?

> The one rule I wanted to follow while doing this is that I use NO
> pointers whatsoever.  But I cannot seem to find the correct syntax for
> working with the object in the ObjectList I need at any particular time
> without them,

The list has an Items property. Give it the index you want, and it gives 
you back a TObject. Type-cast that to the class you want.

-- 
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to