Did you know?

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Did you know?

Post by cogier » Sunday 15th January 2017 1:40pm

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.

User avatar
gbWilly
Posts: 8
Joined: Friday 23rd September 2016 11:41am

Re: Did you know?

Post by gbWilly » Sunday 15th January 2017 4:39pm

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 ;)

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Did you know?

Post by jornmo » Monday 16th January 2017 12:45pm

I did :)

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

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier » Tuesday 17th January 2017 3:30pm

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'?

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Did you know?

Post by jornmo » Wednesday 18th January 2017 4:20pm

_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.

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier » Saturday 21st January 2017 9:49am

Can you give me an example of a 'Constructor' as the information out there is way beyond me!

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Did you know?

Post by jornmo » Sunday 22nd January 2017 4:00pm

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.

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier » Saturday 04th February 2017 3:13pm

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?

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Did you know?

Post by jornmo » Saturday 04th February 2017 5:11pm

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 :)

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier » Thursday 16th March 2017 3:28pm

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest