realbasic-nug
[Top] [All Lists]

Re: Size of Objects in Array

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Size of Objects in Array
From: "Joseph J. Strout" <joe at strout dot net>
Date: Tue, 31 Jan 2006 13:41:09 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <43DFC6B9 dot 8030605 at wxs dot nl>
At 9:21 PM +0100 1/31/06, Leo Van den Brande wrote:

I found no way to generate a list of all windows of a project, irrespective if they are open or not.

There is no way. I'm not even sure that makes sense. How can a list contain both open windows and non-open windows (i.e. windows that do not exist)?

As a workaround I put a copy of a window in an array, when first encountered during recording, and derive other information therefrom.

That seems reasonable.

So, the storage must involve not only the recorded events, but the array of windows as well. That is where I do not succeed. I suppose I need a better understanding of how window information is structured in RB. Perhaps you could give me a hint or direct me to some reading.

Well, first, you seem to be imagining that there is some built-in "save this window to disk" feature. Start by abandoning that notion. There is no such feature. You write code to save basic types to disk: strings, numbers, collections of bytes (see the BinaryStream class in the language reference). Everything else, you must define in terms of these basic elements.

So, if you want to save a list of windows, you make up a file format that can contain a list of windows. Then you write code (using the BinaryStream class, for example) to read and write that format. Nobody can tell you what format you should use; you have to make one up specific to your needs.

Although I could not find it, it is possible, of course, that someone already has made classes or a plugin that would support my needs.

I don't see how. Nobody else has your needs, so how could they have written code to do it?

Here's a sketch of an approach that may help:

1. Define a Class Interface for things that can report their class name; this would have one method, e.g. "ClassName() as String". 2. Implement this interface in every window class you have, so your windows can report their class name. 3. To save your list of windows, write out the class name of each window in your list. That code would look something like:

  for each w As Window in myWindowList
    if w IsA ClassNameReporter then
      bs.Write ClassNameReporter(w).ClassName + ChrB(13)
    end if
  next

where ClassNameReporter is that class interface you defined in step 1, and bs is your BinaryStream. This spits out all the class names to a file, separated by ChrB(13).

4. When you read your file back in, find each class name, and then use a Select Case statement to instantiate a window (or other object) of the specified class.

HTH,
- Joe

P.S. If you haven't gone through the tutorial yet, please do so. You'll learn far more in an hour of that then you'll learn in a week of asking questions here!

--

Joseph J. Strout
joe at strout dot net
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>