Programming Gambas from Zip/DidYouKnow

Shortcuts in Writing Code
Thanks to cogier, stevedee and jornmo on Gambas ''One. https://forum.Gambas.one/viewtopic.php?f=4&t=489''



Double-click a blank area of the form to start typing code for the Public Sub Form_Open event. Double-click a button to start typing code for Public Sub Button_Click. Otherwise, right-click the object or form > click EVENT… > choose the event you want to write code for.

Expansions


If you want to start writing a new sub, type ps  and you will see already typed for you: v  is changed into Private $Var As Type

ds , df  and di  are changed into

Dim sVar As String

Dim fVar As Float

Dim iVar As Integer

Help
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. Selecting a keyword and pressing F2 also does it.

Right-click a tool in the toolbox and help will appear.

Declaring Variables


In preferences (Ctrl-Alt-P) switch on Local variable declaration then in your empty 'Sub' type iCount = 6 and a Dim iCount as Integer automatically appears.

Pausing and Looking at Variables
If the program is paused (you put in a “breakpoint” in a certain place in the code, and the execution reached this place, or you click the Pause button) you can select a variable (drag over it, or double-click it) and you will see its value.

Widen, Shorten and Move Things


If you select the width or height properties of a control, the up or down arrows increase or reduce it by 7 pixels.

If you select the X property of a control, up-arrow moves right, down-arrow moves left by 7 pixels. Similarly in the Y property value box, up-arrow moves down and down-arrow moves up (work that one out) by 7 pixels.

If you want a line or selected lines of code to move up, click in the line and press Alt-UpArrow. Alt-DownArrow moves it or them down.

Many Random Numbers
Dim siRand1, siRand2, siRand3, siRand4 As Short = Rand(0, 9)

This declares four short integer variables and puts a random digit between 0 and 9 into each.

Deleting a Whole Line of Code
Press Shift-Delete anywhere on the line.

Commenting and Uncommenting Lines of Code


Select the lines > Press Ctrl-K to “komment-out” the lines. Ctrl-U with lines selected will un-comment them. (Commenting out means making them into comments so they are not executed.)

Non-Case-Sensitive Comparisons
Use a double equals sign to disregard case. For example, "Hello" == "HELLO" is true. "Hello" = "HELLO" is false.

You can also use a function to compare two strings String.Comp("Hello", "HELLO", gb.IgnoreCase) = 0. String.Comp("Hello", "HELLO") <> 0 is true.