Page 1 of 8

Did you know?

Posted: Sunday 15th January 2017 1:40pm
by cogier
I must have typed 'Open_Form' quite a few times to complete the 'Public Sub Form_Open()', then I discovered that this can be automatically created by double clicking the Form.

I suspect you all knew this but I thought I would share this anyway.

Re: Did you know?

Posted: Sunday 15th January 2017 4:39pm
by gbWilly
There is more of that:
For example, just try double clicking a button on a form.
You'll be in the code editor of that forms class at the Public Sub Button_Click() event with the cursor positioned ready to code.
I use it all the time...

OR

On a form or any control right-click and go to menu item 'events', and click the event you want to code.
Code editor will open the forms class and your event is declared and cursor positioned ready to code.

The Gambas IDE really is one of the best IDE's I have ever used and I'm sure I haven't discovered all of its features ;)

Re: Did you know?

Posted: Monday 16th January 2017 12:45pm
by jornmo
I did :)

Have you tried typing ps+ tab? Or v + tab? Or _n +tab?

Re: Did you know?

Posted: Tuesday 17th January 2017 3:30pm
by cogier
I knew most of these but for variables I use: -
ds [Tab]
df [Tab]
di [Tab]

[Ctrl] + [Alt] + [Enter] from here http://gambas.8142.n7.nabble.com/Questi ... 58228.html is also interesting.

When do you use '_n'?

Re: Did you know?

Posted: Wednesday 18th January 2017 4:20pm
by jornmo
_n is the equivalent of a constructor in other languages. It sort of initialises an object when it is created, i.e. it is called each time you use the NEW keyword.

Re: Did you know?

Posted: Saturday 21st January 2017 9:49am
by cogier
Can you give me an example of a 'Constructor' as the information out there is way beyond me!

Re: Did you know?

Posted: Sunday 22nd January 2017 4:00pm
by jornmo
How is your understanding of object oriented programming?
A class file in Gambas represents the blue print of an object, while a module file represents a static class.
When you've made a class in Gambas, you can create objects from it with

Code: Select all

Private $myObject = New MyClass As "EventName"
Inside the class file, you can use special methods, amongst:

Code: Select all

Public Sub _new()
  ...
End
The code inside this block is executed each time a new object is created. If the class is a graphical control, it would make sense to set the default size, colors and the like in this block.

Re: Did you know?

Posted: Saturday 04th February 2017 3:13pm
by cogier
I have discovered another short cut I didn't know about.

If you hold down the [Ctrl] key and click on a Gambas reserved word (e.g. Public, New, For, etc) the relevant help page is displayed.

But you all knew that didn't you?

Re: Did you know?

Posted: Saturday 04th February 2017 5:11pm
by jornmo
I might have tried it a long time ago since it is the same in Lazarus, but I prefer F2. F2 does the same thing - shows help on Gambas stuff, and takes you to the declaration on other stuff :)

Re: Did you know?

Posted: Thursday 16th March 2017 3:28pm
by cogier
I have found another little gem I thought I would pass on (even though you know it already!)

Open preferences [Ctrl]+[Alt]+P and switch on Local variable automatic declaration then in your empty 'Sub' type iCount = 6 and hey presto a Dim iCount as Integer automatically appears!