Did you know?

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

Re: Did you know?

Post by jornmo » Friday 17th March 2017 12:19pm

I've seen the option, but haven't figured out how it works. Thank you :D

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

Re: Did you know?

Post by cogier » Tuesday 28th March 2017 4:41pm

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.

stevedee
Posts: 42
Joined: Monday 20th March 2017 6:06pm

Re: Did you know?

Post by stevedee » Tuesday 28th March 2017 9:21pm

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"

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

Re: Did you know?

Post by cogier » Wednesday 29th March 2017 3:19pm

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

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

Re: Did you know?

Post by jornmo » Wednesday 29th March 2017 6:30pm

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:

stevedee
Posts: 42
Joined: Monday 20th March 2017 6:06pm

Re: Did you know?

Post by stevedee » Wednesday 29th March 2017 7:09pm

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.

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

Re: Did you know?

Post by cogier » Thursday 30th March 2017 12:06pm

You are both correct. It's good to get the different ideas and points of view. Let's stimulate debate!

stevedee
Posts: 42
Joined: Monday 20th March 2017 6:06pm

Re: Did you know?

Post by stevedee » Friday 05th May 2017 3:52pm

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.

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

Re: Did you know?

Post by cogier » Saturday 06th May 2017 12:52pm

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.

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

Re: Did you know?

Post by cogier » Sunday 11th June 2017 4:41pm

Found this today. If you 'Right click' on a tool in the ToolBox it brings up the help page. ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest