[Gambas-user] define a startup class?

Rob sourceforge-raindog2 at ...94...
Mon May 19 06:16:51 CEST 2003


On Sunday 18 May 2003 23:53, Ed Weinberg wrote:
> I am a Gambas nubee.
> How do I
> "define a startup class in the project properties dialog" called Main or
> something like that?  Troubleshooting says that I need to do that to get
> it to run, but does not tell me how.

You can go into the Project menu, then Properties, then on the General tab 
scroll down a bit and you'll find the startup class option.  Set it to the 
class for your startup form.

That's not all you have to do though.  In VB, if you select a startup form, 
it's automatically loaded and shown at runtime.  In Gambas, the only special 
thing about the startup class is that it contains a public sub called Main() 
which gets executed first.  Into that sub you need to put something like the 
following (a Gambas idiom, basically):

DIM testform AS NEW testform
testform.show

or if you want to be object-orientedly-correct and less VB-like:

DIM myTestForm as new testform
myTestForm.show

The first line loads the form (which would automatically happen in VB the 
first time you referred to it as an object) and the second shows it (which 
only automatically happens in VB if the form is the startup form.)  There is 
a "load components immediately at startup" option in project properties but 
that doesn't seem to make the above code unnecessary yet.  This may be 
because VB forms have a class built into them whereas Gambas keeps the class 
separate from the form layout, but I haven't looked too closely yet.

I'm hoping to hack the IDE to hide some of this and make some of it automatic, 
maybe even provide an option to emulate the VB startup form behavior and hide 
Sub Main in that case.  I know this is contrary to what Benoit wants to do 
(make a VB like language that Linux people won't sneer at too badly) but I'll 
probably submit the patches anyway when things are working just in case.

Rob





More information about the User mailing list