I can answer my own question :-) ... Several hours after I posted I recognized a key mistake I made in my thinking and coding. I was passing a reference to a TForm. Rob made this general point, somehow it just took me awhile to recognize it in my own code. Passing a reference to TForm, the parent to all forms, left me with access to all TForm properties in my descendant forms. That's a good, generalized way to do things--as long as I only need to access TForm properties. The problem--obvious to all of you--is that any GUI form we use inherits from TForm and has additional properties, (component) fields, etc. None of these would be available when I pass a reference to TForm. It's basic, fundamental OOP. ... I wish I'd recognized this before posting.
My thanks again, however, to both of you for responding. -- Al ---------------------------------------- > From: [EMAIL PROTECTED] > To: [email protected] > Subject: RE: Scope and Message Passing > Date: Tue, 23 Jan 2007 19:07:45 -0800 > CC: [EMAIL PROTECTED] > > > Hi Rob -- > > Thanks for taking the time to write such a lengthy and educational response; > I really appreciate it. The funny thing is, I'm still unsure about what to > pass when trying to facilitate communication between classes--even if I'm OK > with the difference between passing by value and by reference, that TForm1 is > descended from TForm, that the var declaration (below) creates only memory > space pointing to the address of an instance of type TForm1, etc. > > So, if it's OK with you, let me give you a silly situation, and ask you about > what the code would look like. I'll use default values throughout, and start > with a form, a memo, and a button. Unit1 would include this code: > > type > TForm1 = class(TForm) > Memo1: TMemo; > Button1: TButton; > private > { Private declarations } > public > { Public declarations } > end; > > var > Form1: TForm1; > > Create a new class, TIni, to make the following two things happen. When Form1 > closes, the form's width and the memo's lines should be saved to an ini file. > (If it's easier to save Memo1.Text than Memo1.Lines, that's OK.) I assume the > procedure to write configuration info to disk would include ... > > procedure TIni.WriteConfig (???); > var > aIniFile: TIniFile; > begin > //writes user info to config.ini > AIniFile := TIniFile.Create(ExtractFilePath(Application.EXEName) + > 'config.ini'); > try > with AIniFile do > begin > WriteInteger('Config', 'Width', Form1.width); > //something like a WriteString method to save Memo1's Text, or a series > of WriteStrings to save each of Memo1's Lines > end; > finally > aIniFile.Free; > end; > end; > > If there's other types of variables, references, etc. that are commonly > passed between objects, you might save a later posting from me by mentioning > them now :-) > > Thank you again, and reply only if you find the time. But know that your > replies and those of others make a difference to me. If there's a basic > reference you think I ought to look at, feel free to mention it. I'd love to > take a class, but Delphi-based instruction seems to be unavailable. -- Al > > _________________________________________________________________ > Type your favorite song. Get a customized station. Try MSN Radio powered by > Pandora. > http://radio.msn.com > _______________________________________________ > Delphi mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi _________________________________________________________________ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

