Page 2 of 10

Re: Did you know?

Posted: Friday 17th March 2017 12:19pm
by jornmo
I've seen the option, but haven't figured out how it works. Thank you :D

Re: Did you know?

Posted: Tuesday 28th March 2017 4:41pm
by cogier
Here is another find - Try this one: -
Public Sub Form_Open()
Dim sTemp1 As String = "hello"
Dim sTemp2 As String = "HELLO"

If sTemp1 == sTemp2 Then Print "Yes" Else Print "No"

End
The "==" is a non case sensitive comparison.

Re: Did you know?

Posted: Tuesday 28th March 2017 9:21pm
by stevedee
cogier wrote: Tuesday 28th March 2017 4:41pm Here is another find - Try this one: -
If sTemp1 == sTemp2 Then Print "Yes" Else Print "No"

...or
    If String.Comp(sTemp1, sTemp2, gb.IgnoreCase) = 0 Then Print "yes" Else Print "No"

Re: Did you know?

Posted: Wednesday 29th March 2017 3:19pm
by cogier
You can shorten the line: -
If String.Comp(sTemp1, sTemp2, gb.IgnoreCase) = 0 Then Print "yes" Else Print "No"
To: -
If Comp(sTemp1, sTemp2, 1) Then Print "No" Else Print "yes"
Unless you particularly wanted to compare two UTF-8 strings

Re: Did you know?

Posted: Wednesday 29th March 2017 6:30pm
by jornmo
It is not recommended to use 1 as a replacement for the comparison mode. If there are internal changes to Gambas, you could end up with bad results.

http://gambaswiki.org/wiki/cat/comp

And, it really makes no sense for others who read the code, and who in their right mind remembers what each integer constant means :lol: :shock:

Re: Did you know?

Posted: Wednesday 29th March 2017 7:09pm
by stevedee
cogier wrote: Wednesday 29th March 2017 3:19pm You can shorten the line...
Hi cogier, you are right, it can be trimmed down a bit.

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. Using the String object helps because when you type "String." you get a full list of available methods and properties. 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, I know that that is not the point of this "Did you know?" thread, I'm just rambling again.

Re: Did you know?

Posted: Thursday 30th March 2017 12:06pm
by cogier
You are both correct. It's good to get the different ideas and points of view. Let's stimulate debate!

Re: Did you know?

Posted: Friday 5th May 2017 3:52pm
by stevedee
Some of the undocumented stuff in Gambas is common to VB. For example; if you pause your program in the IDE (maybe as a result of hitting a break-point) you can double click on variables, and then tooltip-text will display the current value for a few seconds.

You can do the same thing with expressions by marking the whole expression (e.g. put the cursor at the start of the expression, hold down <shift> and then click the end of the expression).

If you need longer to view the result (maybe its a string of text) you can copy the expression with <ctrl><c>, click in the print/evaluation bar, use <ctrl><v> to paste, then press enter to evaluate.

Double-clicking on class instance (object) names, arrays and file handles is even more interesting, as this opens a persistent object viewer.

Re: Did you know?

Posted: Saturday 6th May 2017 12:52pm
by cogier
I knew most of this but I had always selected a variable to find it's value, I didn't know you could double click it as well.

Re: Did you know?

Posted: Sunday 11th June 2017 4:41pm
by cogier
Found this today. If you 'Right click' on a tool in the ToolBox it brings up the help page. ;)