Did you know?
Re: Did you know?
I've seen the option, but haven't figured out how it works. Thank you
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
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.- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
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 stringsRe: Did you know?
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
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
Re: Did you know?
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.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
You are both correct. It's good to get the different ideas and points of view. Let's stimulate debate!
Re: Did you know?
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.
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.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
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.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
Found this today. If you 'Right click' on a tool in the ToolBox it brings up the help page.