realbasic-nug
[Top] [All Lists]

Re: Why am I getting 2 copies when I do an f.show

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Why am I getting 2 copies when I do an f.show
From: Thomas Reed <tareed at bitjuggler dot com>
Date: Mon, 29 Nov 2004 17:37:48 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <200411292222 dot iATMMggu020434 at mac dot com>
On Nov 29, 2004, at 5:23 PM, Steve Smith wrote:

I have a form that launches another form with f.show.

A form? What's that? (Hint: we call 'em "windows" here, this ain't VB.) What's f? A window, I assume.

Is there something in this code in the open event that's causing another
instance to be shown?

I believe so, if I'm interpreting this right...

    winselect.lstnames.columnCount=5
    while not rs.eof
      winselect.lstnames.addRow rs.idxField(1).Value
      lp = winselect.lstnames.lastindex
      winselect.lstnames.cell(lp,1) = rs.idxfield(2).value
      winselect.lstnames.cell(lp,2) = rs.idxfield(3).value
      winselect.lstnames.cell(lp,3) = rs.idxfield(4).value
      rs.movenext
    wend

You said this code is in the Open event, and I'm going to assume that you meant the Open event of a window named winselect. I'm also going to assume you have, elsewhere, created an instance of winselect by doing something like this:

  dim w as winselect

  w = new winselect

If that's the case, the code above causes the error by referring to winselect instead of self. In REALbasic, windows can be implicitly instantiated by simply referring to them by name. So a line of code like this:

  winselect.title = "blah"

actually creates an implicit instance of winselect. Further references to winselect will refer to that implicitly opened instance, which will be *different* from the instance you might have created using 'new'.

So, just remove the references to winselect from code contained in winselect. Change it to self, or simply remove it entirely. For example, in code inside winselect, the line of code above that sets the title is syntactically equivalent to:

  title = "blah"

Hope this helps!

-Thomas

Personal web page: <http://homepage.mac.com/thomasareed/> My shareware: <http://www.bitjuggler.com/> Free REALbasic code: <http://www.bitjuggler.com/extra/>

There are 10 kinds of people in the world -- those who understand binary
numbers and those who don't.

_______________________________________________
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>