Did you know?

Post your Gambas programming questions here.
User avatar
Got2BeFree
Posts: 91
Joined: Saturday 26th November 2016 2:52am
Location: Lost

Re: Did you know?

Post by Got2BeFree »

Did you know...
While in form view, you can right-click-drag (just like selecting text to copy) and select the objects?
sholzy

I'm wondering around lost in the past, not knowing where the present is.
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Did you know?

Post by Cedron »

That there is a destructor function for Gambas objects called _free?
'========================================================'
Public Sub _new()

        Randomize

End
'========================================================'
Public Sub _free()

        Print "I'm Free"

End
'========================================================'
There are others as well.

From gambas.h, line 1193:

Code: Select all

  Special methods that can be declared in a class
  -----------------------------------------------

  _get        array reading operator
  _put        array writing operator
  _new        constructor
  _free       destructor
  _next       next iteration of an enumeration
  _call       called when the object or the class is used as a function
  _unknown    called when the name of the property or method is unknown
Just found the documentation link:

http://gambaswiki.org/wiki/cat/special
.... and carry a big stick!
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Did you know?

Post by Cedron »

DYK that Gambas allows top and bottom testing in the same loop?
        Dim i, j As Integer
        
        i = 10
        
        Do While i > 8
           j = i * i 
           Print i, j
           Dec i
        Loop Until j < 50
Awesome!

Change the 8 to 4, run it again.
.... and carry a big stick!
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier »

Did you know that while in the Gambas IDE and editing your code, holding the shift key down and pressing 'Del' will delete the whole line?
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Did you know?

Post by Cedron »

DYK that you can comment an entire block of lines by

1) Highlighting them

2) Either press the [Ctrl-k] keys or click on the tiny button with an apostrophe on it above the text editing area.

To uncomment the lines, highlight, then press either [Ctrl-u] or click on the tiny button with an apostrophe and a tiny red x.

That's darn handy.
.... and carry a big stick!
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Did you know?

Post by Cedron »

DYK that Gambas also provides for initialization and termination routines at the class level, similar to the _new() and _free() calls for instances.
'=============================================================================
Static Public Sub _init()
 
' Print "GamePad._init"

' Print Application.Path
' Print Application.Dir
' Print Application.Title
' Print Application.Name
        
End
'=============================================================================
Static Public Sub _exit()

'        Message.Info("GamePad._exit")
    
End
'=============================================================================
.... and carry a big stick!
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Did you know?

Post by cogier »

If you want only the data loaded from a file and Split into an array then try this: -
Dim sData As String[] = Split(File.Load(Application.path &/ "data"), gb.NewLine, "", True)
Image

Click here for a larger picture
The dialogue box on the left is the file and on the right is the array.

Check out the IgnoreVoid command here
User avatar
Technopeasant
Posts: 138
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Did you know?

Post by Technopeasant »

This should be really helpful for a project of mine. Thanks.
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Did you know?

Post by stevedee »

Just to say that the excellent Gambas Buch programming book listed on the Gambas One resource page is also available in English:-
https://gambas-buch.de/dwen/doku.php?id=start
User avatar
sjsepan
Posts: 68
Joined: Saturday 12th October 2019 10:11pm
Location: Leeper, PA, USA
Contact:

Re: Did you know?

Post by sjsepan »

(moved here from General)
Haven't seen this mentioned here, although the Help wiki confirms it. It may initially surprise folks coming from VB that Sub / Function / Procedure 'are synonymous'.
Its not a problem; it just means that when you use Sub or Function your are merely following a naming convention. :o

That means this works:
' Gambas module file

Public Sub Main()

    Print Procedure1("Hello world")
    Print Procedure2("Hello world")
    Procedure3("Hello world")
    Print Procedure4("Hello world")
    Procedure5("Hello world")

End

Private Function Procedure1(val As String) As String

    Return String.Upper(val)

End

Private Sub Procedure2(val As String) As String

    Return String.Upper(val)

End

Private Function Procedure3(val As String)

    Print String.Upper(val)

End

Private Procedure Procedure4(val As String) As String

    Return String.Upper(val)

End

Private Procedure Procedure5(val As String)

    Print String.Upper(val)

End

Post Reply