Again, thanks a bunch, Maarten!

Maarten Wiltink wrote:
> 
> "W. D." <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Maarten Wiltink wrote:
> [...]
> >> Start with lifting out the innermost expressions. It's a lexical
> >> operation, no understanding required. Repeat until you start to see
> >> what happens.
> 
> > The problem is, I don't know how to index the CLASS and RECORD
> > variables.  These are the 'innermost expressions', yes?
> 
> I'm not talking about indexing at this point, but only about moving
> subexpressions into temporary variables.
> 
> However, you can't index classtype references or record type
> values in Delphi. You must have an array of them. 

This is the critical information that I needed.  Apparently,
in C++, indexing pointer variables (whether they are strings,
records, classes, or whatever) is just a matter of tacking
on an index:

  SomeComplicatedRecord[i].SomeMethod 


>C arrays look
> different. Are you sure you don't have an array? Are you sure
> you _shouldn't_ have an array?

I guess I really *SHOULD* have an array in Delphi.  Otherwise,
how can I cycle through each member?

This requires converting the type from a pointer to a non-pointer
type.  And of course, much of the code that references the
variable will also need to be rewritten.

I've begun to do this but, am wondering how to 
deallocate the memory for an Array of Record.
This record, 'Was_a_pointer', is declared in the
'Private' section of a class.  In the Destructor,
this is how it was deallocated:

  // C++: delete[] Was_a_pointer;


When I try to deallocate this array, I get
all sorts of errors.  None of the following
work:

  Was_a_pointer := NIL;    
  FreeMem(Was_a_pointer);
  @Was_a_pointer := NIL;
  Was_a_pointer.Free;
  Dispose(Was_a_pointer);

Is an array that is declared in a class automatically 
disposed of when the class is destroyed?  If not, 
what is the proper way to free memory allocated to 
arrays of records?

Thanks soooo much for all your wisdom and insights!

Start Here to Find It Fast!� -> http://www.US-Webmasters.com/best-start-page/
$8.77 Domain Names -> http://domains.us-webmasters.com/


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

Reply via email to