Subject Re: FORM NAME VS CLASS NAME
From Mustansir Ghor <mustan31@hotmail.com>
Date Mon, 12 Mar 2018 02:23:45 -0400
Newsgroups dbase.getting-started

Dear Mervyn

Thank you.

If by all means xyz.wfm was closed, then it would result in error. is it? Further can this also apply to menu files also, in that case by closing the form, does menu file also gets closed (if there is attached menu file to a form).

Best Regards
Mustansir


Mervyn Bick Wrote:

> On 2018-03-11 9:56 PM, Mustansir Ghor wrote:
> > Dear Mervyn
> >
> > There was a mail sometime back I cant get it now. It was about filename eg xyz.wfm having different class name . That is class abcForm of Form. You had pointed its impact.
> >
> > Can I recollect the mail or I wonder file  xyz.wfm having class abcForm still works. How?
> >   Because although abc.wfm exit it has not been referenced anywhere in xyz.wfm.
> >
> > best Regards
> > Mustansir
> >
>
>
> If you open a new form in the form designer and then press F12 to open
> the sourcecode editor you will see that dBASE has created the following
> code.
>
>
> parameter bModal
> local f
> f = new UntitledForm()
> if (bModal)
>     f.mdi = false // ensure not MDI
>     f.readModal()
> else
>     f.open()
> endif
>
> class UntitledForm of FORM
>     with (this)
>        height = 16.0
>        left = 105.5
>        top = 0.0
>        width = 40.0
>        text = ""
>     endwith
>
>
> If you close the sourcecode editor and carry on building your form you
> eventually get to the stage where you save your form.  If you tell dBASE
> you want to the file to be xyz.wfm dBASE will change Untitled in the
> code to xyz before it saves the file.  Now, when you open xyz.wfm in the
> sourcecode editor you will see that the code has change to
>
> parameter bModal
> local f
> f = new xyzForm()
> if (bModal)
>     f.mdi = false // ensure not MDI
>     f.readModal()
> else
>     f.open()
> endif
>
> class xyzForm of FORM
>     with (this)
>        height = 16.0
>        left = 105.5
>        top = 0.0
>        width = 40.0
>        text = ""
>     endwith
>
>
> If form xyz.wfm is not quite what you want and you want to try a
> different layout you don't really want to modify xyz.wfm because if you
> don't like the changes you have to put everything back where it belongs.
>
> Instead of changing xyz.wfm you use Save AS and save the file as
> xyz1.wfm and perhaps even xyz2.wfm and xyz3.wfm as you try different
> things.  The trouble is that when you save xyz.wfm to xyz1.wfm (or any
> thing else) dBASE doesn't automatically change the classname.  It is
> still xyzForm in all of the files.
>
> When you create an instance of a class by running xyz.wfm Windows
> creates xyzForm in memory.  If you try to create another instance of the
> same class when you run xyz1.wfm Windows says "Ah. I've already got
> that" so it doesn't make a new copy it simply increments a counter. When
> you run the two forms dBASE runs the same instance no matter which form
> you run.
>
> You copied some code from xyz.wfm to abc.wfm (or the other way round - I
> can't remember now) to act as a stripped down example.  I said at the
> time that it didn't matter in that case as nobody else was likely to
> have a class xyzForm.  It could, however, give you problems on your
> computer if you run xyz.wfm and abc.wfm.
>
> I pointed out that to avoid potential problems one should get into the
> habit of changing the classname in the code to match the filename when
> you save code to a new filename.
>
> Mervyn.
>
>
>
>
>
>
>
>
>