firstInstances??

Discussions about design and architecture principles, including native JADE systems and JADE interoperating with other technologies
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

firstInstances??

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:19 am

by JADE Kid - Ray Hidayat >> Tue, 14 Mar 2000 7:02:25 GMT

Okay, so I know the firstInstance method.

someClass := SomeClass.firstInstance;

But what if I want to point to the firstInstance of a form?
this doesn't work:

form := Form.firstTransient;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: firstInstances??

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:19 am

by Craig Shearer >> Tue, 14 Mar 2000 7:59:37 GMT

No, this isn't how it works.

For there to be an instance of a class, one must have been created. When you paint a form in the Painter, you are actually creating a persistent instance of the Form class.

To use a form at runtime, simply create it:

vars
form : MyForm;
begin

create form transient;
form.show;

etc.


Also, your code below would have been clearer as:

someObj := SomeClass.firstIsntance;

as you're actually getting an object, not a class.

Craig.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: firstInstances??

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:19 am

by David Mitchell >> Tue, 14 Mar 2000 9:03:28 GMT

I think what Ray is meaning Craig, is that he has forms open, and wants to refer to them through code. You can grab forms using the app.getForm(name : String): Form; method.

--
David Mitchell
JADE Kid - 1998
www.jadekids.com

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: firstInstances??

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:19 am

by JADE Kid - Ray Hidayat >> Wed, 15 Mar 2000 3:04:08 GMT
I think what Ray is meaning Craig, is that he has forms open, and wants to refer to them through code. You can grab forms using the app.getForm(name: String): Form; method.

Yes that is what I meant. Thanks for that.
vars
form : MyForm;

begin
create form transient;
form.show;

etc.

About this code, you don't need to say transient when when you create it. It works without it.

Ray Hidayat
JADE Kid - 2000
http://www.jadekids.co.nz
(Thanks to David Mitchell [JADE Kid - 1998] for the 'footer')

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: firstInstances??

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:19 am

by Craig Shearer >> Wed, 15 Mar 2000 8:45:49 GMT

That's true, but I believe it's good practise to document the code when creating objects as to what lifetime object you're creating. For example, I often write:

create customer persistent;

even though I could leave persistent off.

For some classes, there are times when you want to create a persistent and other times when you need to create a transient instance. For these examples, the persistent/transient modifier is required, and also helpful from a documentation perspective.

Craig.


Return to “Design and Architecture”

Who is online

Users browsing this forum: No registered users and 15 guests

cron