Page 5 of 10

Re: Did you know?

Posted: Saturday 2nd November 2019 5:41pm
by sjsepan
That of the gui apps that you can create*, including ...

'Graphical application'**, 'GTK+ 3 application', 'GTK+ 2 application', and 'QT application',

...the following do not have a Toolbar control in the 'Container' category in the form designer...

'Graphical application'**, 'GTK+ 2 application'

...so you will need to work around that by using something else, like perhaps a Panel control.
_______________
* -- observation made in Gambas 3.14
** -- (Gtk/Qt switcher)

Re: Did you know?

Posted: Saturday 2nd November 2019 6:29pm
by sjsepan
That in a sub-class you need to use the Me keyword (as in Me.SomeParentMember) in order to access members of a parent class.

You do not need to do anything special to reference those same members (assuming they are public in the parent class) in order to access them from a client of the sub-class.

observed in Gambas 3.14

Re: Did you know?

Posted: Thursday 14th November 2019 5:12pm
by stevedee
If you spend a lot of time coding in Gambas, go to menu Tools > Preferences > Code Snippets and look to see if there are any shortcuts that you may be able to use.
CodeSnippets.png
CodeSnippets.png (129.5 KiB) Viewed 48839 times
I wish you luck if you plan to memorise them all!

You can also make up and add your own, as is the case with "dx" in the list above.

To use a Code Snippet while in the editor, just type the letter(s) followed by the <TAB> key.
Example: c <TAB>
Private Const Name As Type = Value
...where "Name" is highlighted ready to over-write.

Re: Did you know?

Posted: Friday 17th January 2020 5:54am
by grayghost4
try this :
   If Dialog.SelectDirectory() Then Return
  Print Dialog.Path
  Print File.Dir(Dialog.Path)
  Print File.Dir(File.Dir(Dialog.Path))
 Print File.Dir(File.Dir(File.Dir(Dialog.Path)))
will produce this:

/home/mhc/Documents/workinggambas/printchecks
/home/mhc/Documents/workinggambas
/home/mhc/Documents
/home/mhc

But you all know that :D

Re: Did you know?

Posted: Tuesday 3rd March 2020 6:22pm
by cogier
There is a very useful tool in the IDE. Right click>Advanced>Paste special.. and you get this: -

Image

Re: Did you know?

Posted: Sunday 19th April 2020 11:02am
by cogier
Did you know that if you have a situation like:-
Public Sub Form_Open()

  Setup
  Start
  SaveIt

End
Now you want to find the bug in the 'Start' routine which is buried somewhere in the 200 line of code below. Well, just put your cursor on 'Start' and press [F2] and you will be taken to that 'Sub'. Simples! ;)

Re: Did you know?

Posted: Monday 4th May 2020 7:25am
by Serban
stevedee wrote: Wednesday 29th March 2017 7:09pm [...] But what I like about Gambas and VB is that code is easy to read if you don't take too many short-cuts. After all, if you like terse code, why not use Python, C or C++? [...] For beginners and the non-fluent (like me) the very wordy nature of Gambas is a big plus. [...] And using constants like gb.IgnoreCase saves having to remember what "0" or "1" means.
I didn't know about the "==" trick, but I have to say I don't like it for similar reasons. Where "==" crops up in other languages, it normally means a logical comparison. So I don't know why it means case-insensitive string compare in Gambas. [...]
Sorry if I dissapoint anyone, but I strongly agree with stevedeee.
The very definition of a high level language, is how close to native human language is.
This is why I chose RapidQ back in 2000's. It is very much like Gambas although there are important differences. Then I moved to Gambas: both allow wrtiting code that can be understood years after writing it, given the fact that you use a proper variable/ procedure naming system.
As you could see, all names I use are verbose and this is on purpose. This allowed me to find some snippets of code in a RapidQ project with 5,600+ lines of code, in less than 5 minutes when I was looking for a particular solution for DirLister. And this happened after 15 years of break. I never touched any RapidQ code since late 2005.
While using numbers instead of character names for various kinds of situations might be tempting at first sight, it makes the code highly unreadable.
While I was still active in RapidQ community, I needed to get info on some code and asked the authors. It turned out that they were unable to read and understand their own code, exactly for this reason: they thought that using short names is enough. Time, proves this approach highly counter-productive.
On the other hand, verbosity is time-consuming, I know and on the short term, it often looks a burden, or worse: a curse...
On the long run however, I had the chance to verify that on my own code:
  • Clumsy naming, few (or worse: zero) comments: I had to rewrite the code from scratch.
  • Verbose naming, verbose comments, where needed (long, complex procedures): I could easily improve, copy/paste the code, even after 15 years.

On top of that, I must mention one "small detail", but significant in this context. I am the lazy kind. If there is a way/path that is 10 meters long and I can find a 9 meters long one, I'll go for the 9 meters. Might be risky? Yeah... Still... Far more than that...
I belive that all programmers go into that category.
Why else would they spent so much time coding, other than building a shorter path to a particular outcome?
For example: At first sight, I almost hated the so called "Hungarian notation". After a few weeks of working at a long code, it suddenly blew into my eyes: how was I supposed to give a meaningful name to a certain type of variable, inside a 300 lines procedure, with lots of types of variables? All related, all intertwinned?
Was awfully hard in the beginning, but... eventually I got used to that too...
So, instead of "DirPath, IsDirPath", "strDirPath, boIsDirPath" looks more obvious than the previous. While you are at the procedure's declaration line, you see what is what, but later, in code, everything gets blurred.

Re: Did you know?

Posted: Monday 4th May 2020 8:05am
by Serban
didier18 wrote: Thursday 17th May 2018 9:43am [...] It is possible to compare values, see which routine is called by which routine and optimize its code. To see the execution time of a command, a routine and even a complete program. This tool can be found in the menu /Debug/Activate profiling.
Once this menu is selected, launch the program to be tested as you would normally do... Then close your program. A window will open (as in the example) and you can view the profiling.
Even louder... It is possible to save the profiles, which allows you to compare the evolution with the different versions of your program. [...]
Thank you very much!
That is really awsome!
Extremely useful.
Analysing HTSnippets, I came to find out that my intuition serves me very well! :)
What will be really useful is analysing DirLister, though.
Although it's difficult to improve the speed of some procedures, maybe I can find useful ideas watching the insights from the Profiler's report.

Re: Did you know?

Posted: Sunday 10th May 2020 12:41am
by Technopeasant
I agree up to a point Serban, but I do think there are times when shorthand is easier to read.

For example, I use Var += 1 instead of Var = Var + 1 because, also being the lazy kind, it takes less time to read and decode.

It depends on the context.

My biggest beef is code that just doesn't load any more for some reason. I find Gambas code better in this case than say Python, even when it is Gambas 1 or 2 code.

Re: Did you know?

Posted: Thursday 17th September 2020 2:51pm
by cogier
1/. If you use the search window at the top of the IDE all the occurrences will appear at the bottom of the IDE. Just click on one to be taken to that line in your code.

Image

2/. If you put a button in a HBox the button is always forced to the left which means you need a Spring to force the button to the right. Well just changing the HBox Invert property will produce the same result, no Spring needed!

3/. If you use Public Sub _new() in your program you can set up items without triggering any events. Say you have a slider that acts as a volume control, you need to set the volume as your program starts but the last thing you need is the Public Sub Slider1_Change() routine being triggered while the slider is adjusted. Just put the necessary code in Public Sub _new() and no event will be triggered.