[Gambas-user] define a startup class?

Rob sourceforge-raindog2 at ...94...
Mon May 19 15:23:36 CEST 2003


On Monday 19 May 2003 04:48, Benoit Minisini wrote:
> When you have a form named Form1 in VB, and you type Form1.Show, what
> happens in the background ? Exactly what you must do by hand in Gambas: the
> form is instanciated, and the instance is given the same name as the form.

Indeed, and that's why I hope to automate and hide the process in Gambas.  
There's no need for the user to see it if it's the same in every project.

> 1) The newbie is confused, because class and instance of this class have
> the same name. So the newbie don't really understand what he does exactly.

True, and it's kinda hard to reuse forms in VB.  Nonetheless, there are a lot 
of VB programmers who are going to be interested in Gambas and I see no 
reason to hinder them with good programming style ;)  The truth is, even in 
your examples to date you don't have any examples of form reuse, and I expect 
most VB programmers are used to the idea that forms only ever get loaded 
once.  So I think that making it optionally easy for the user (since this is 
BASIC after all) is more important than Java-like reuse of everything.

> 2) The form is instanciated when you try to use the form class as a form
> instance. You save two lines of code and one variable at first, but when

Far more importantly, you save a learning curve.  People expect to be able to 
just create a form, hit F5 and have it come up.  That's the beauty of VB, the 
ability to make it do something visible without writing a single line of 
code.  VB's appeal has never been clean design or good programming style or 
any of that stuff, it's been the fact that it's easy to learn and use.  And 
Linux programmers who value "technically correct" solutions are already using 
C/C++/Java, whereas VB programmers currently have nowhere to go.

> you want to exit the program, you must be very careful not to make a
> reference to a closed form, elsewhere this form is recreated, and your
> program does not exit ! (I had this problem many times in my VB programs)

Having never actually unloaded a form in VB except to force an exit (by 
unloading the main form), I never ran into this problem.

> Maybe I could have the same behavior with forms on Gambas. But I think that
> the disadventages are greater than the advantages.

We have different goals.  You're looking to make something that's like VB, 
only good.  I'm looking for something that will make VB programmers as 
comfortable under Linux as Openoffice makes Word users.

> Modifying the IDE will not help you... It is a functionnality that must be
> add to the interpreter: something like auto-instanciating class. But I
> don't even know if it is technically possible at the moment !

Sure I can.  As far as the "press F5 without having written any code" issue 
goes, I can add something to the properties dialog that says "Make VB style 
project with this startup form:", create a file called "vbproj.class" which 
is hidden from view in the IDE and contains a sub main that instantiates and 
shows the desired form.  vbproj.class becomes the startup class as far as 
Gambas the language is concerned, just as myfilename.vbp is the "startup 
class" of a VB project, but the user never sees or edits it.  That part's 
pretty trivial.

Since you don't seem to have implemented project-wide global variables or 
include files yet, I haven't figured out a way to instantiate all the forms 
in the project at startup yet (which would take care of the "form being 
instantiated the first time you refer to it" problem), nor how to refer to 
those forms outside the startup class if you do, so I may be stuck there for 
now.  It seems to me the easiest way to take care of that without bothering 
non-VB-familiar Gambas users would be to make a compiler directive like "USE 
GLOBALS" or something that extends the scope of public variables to the 
entire project.  But even without any of that, just having VB programmers or 
novice Gambas programmers make a form, run it and have it show up 
automatically will be a breakthrough in making Gambas seem easier than it is, 
I think.

I know it's ugly, but so is VB and I'm trying to recreate the VB experience 
using Gambas. ;)  I am utterly uninterested in teaching VB programmers how to 
be better programmers of other languages, I just want them to be able to say, 
"Hey, there's an equivalent tool for Linux that's just as easy."  I never 
tried to teach Word users LyX or LaTeX and I'm not going to try to teach VB 
users about encapsulation and strongly typed variables.  I'm hoping to at 
least get a tool together that recreates their .frm files as Gambas forms, 
even if I can't convert the code automatically.  And I know that's not your 
goal, and so I'll try to avoid stepping on your toes (I can't imagine that 
I'll touch the interpreter, for one thing.)  I mean no disrespect by any of 
this; I just want to make life easier for my users.

I suppose this really belonged on gambas-devel, sorry about that.

Rob





More information about the User mailing list