Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!cbmvax!vu-vlsi!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: scroll bar problem Keywords: programming issue Message-ID: <2642@masada.cs.swarthmore.edu> Date: 3 Apr 89 15:07:13 GMT References: <425ca822.1285f@maize.engin.umich.edu> Reply-To: jackiw@masada.UUCP (Nick Jackiw) Distribution: usa Organization: Visual Geometry Project, Swarthmore College, PA Lines: 35 In article <425ca822.1285f@maize.engin.umich.edu> rpitt@caen.engin.umich.edu (Raymond Jeczen Pittman) writes: > I am writing an application that uses multiple windows and I would > like to know how I can access the control list in the window record > to reference a particular controlhandle such as the scroll bars. I > don't declare my scroll bar handles globally, I like to keep it > dynamic. The control is declared locally in a procedure but the > control is tagged to the window with the NewControl rom call. > Any ideas? > Thanks. > R.J. Pittman rpitt@caen.engin.umich.edu ---- Sure you can do it this way if you want. TheWindow^^.ControlList heads a linked list of all of your controls. How do you recognize a particular control (e. g. horiz scroll) once you've got the ControlList? You'll have to slap an identifying constant into the control's RefCon field. At this point you should begin to wonder how dearly you wish to stick to those principles of application hygene learned in CS courses. While you have no global variables, and therefore are guaranteed to enforce "side- effect-free" discipline, you DO have a global declaration of the identifying constant, which makes your code just as difficult to read as a global var; AND you lose efficiency because you have to search the window's entire control list instead of having a variable already pointing to your control. As long as you document thoroughly that a routine relies upon, or sets, a global var, why not use one? Their disadvantages are all theoretical, their advantages are all immensely practical. -- +-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+ | nicholas jackiw | jackiw%campus.swarthmore.edu@swarthmr.bitnet | +-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+ "Ah...I've got this CHRONIC pain." _True Believer_