1st Time User Gambas Questions(Former VB6 user)

User avatar
Quincunxian
Posts: 67
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Quincunxian » Monday 12th August 2019 1:42am

Hi Lavos - can you post the code in modDatabase where .FileExist is declared please.
Cheers - Quin.
I code therefore I am

Lavos
Posts: 15
Joined: Sunday 28th July 2019 12:22pm

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Lavos » Monday 12th August 2019 7:56am

Quincunxian wrote: ↑
Monday 12th August 2019 1:42am
Hi Lavos - can you post the code in modDatabase where .FileExist is declared please.
Image
Does this helps? 8-)

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

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by cogier » Monday 12th August 2019 2:03pm

That helped me. :P

Just use: -
Return True
not
.FileExist = True

User avatar
Quincunxian
Posts: 67
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Quincunxian » Monday 12th August 2019 10:32pm

Yeah - I don't know how I missed that. *sigh*
Cheers - Quin.
I code therefore I am

Lavos
Posts: 15
Joined: Sunday 28th July 2019 12:22pm

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Lavos » Tuesday 13th August 2019 2:55am

cogier wrote: ↑
Monday 12th August 2019 2:03pm
That helped me. :P

Just use: -
Return True
not
.FileExist = True
Thank you. That makes more sense. I'm still in a habit of coding in vb6. I'm still really trying hard to adapt to gambas way of understanding how it works.😎

Anyway ive read the documentation for structs time and time again because it imo, vague... so im jyst gunna ask, is it possible to pass a value through structs? Im just trying to avoid using a class according programming standards, using class as a replacment for UDTs (structs) is bad practice.

-regards, Lavos and the community.

Lavos
Posts: 15
Joined: Sunday 28th July 2019 12:22pm

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Lavos » Tuesday 13th August 2019 3:11am

Lavos wrote: ↑
Tuesday 13th August 2019 2:55am
cogier wrote: ↑
Monday 12th August 2019 2:03pm
That helped me. :P

Just use: -
Return True
not
.FileExist = True
Thank you. That makes more sense. I'm still in a habit of coding in vb6. I'm still really trying hard to adapt to gambas way of understanding how it works.😎

Anyway ive read the documentation for structs time and time again because it imo, vague... so im jyst gunna ask, is it possible to pass a value through structs? Im just trying to avoid using a class because according programming standards, using class as a replacment for UDTs (structs) is bad practice.

-regards, Lavos and the community.

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

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by cogier » Tuesday 13th August 2019 2:59pm

I have never used structs as Gambas says in capitals 'DON'T USE STRUCTURES, UNLESS YOU HAVE TO!'

What are you trying to acheive? Pehaps we can find an alternative.

User avatar
Cedron
Posts: 103
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Cedron » Tuesday 13th August 2019 3:31pm

I've been busy for a little while so I have left this thread alone.

First a general comment for Lavos: I, too, am a long time VB6 (actually VB3-6) user and I found Gambas at the beginning of the year. My impression has been very very favorable. I see Gambas as a big improvement over VB6, sort of like VB done right. I joke it should have been called "Inc VB" (a word play on C++).

Having said that, there are a few things I would have liked to have been done differently. Foremost, is the lack of a line continuation character. I have requested it and it has been deemed too difficult to implement. I hope this is rectified in the future. I do find it a little annoying to have to dim all my variables, I would like to see either type declaration characters used (like VB), or a default type of Integer (instead of Single like orginal BASICs).

Those are the major ones.

Hitting the issues raised in this thread:

I much prefer having "Return (value)" rather than "(function_Name) = (value)" as the way to return values from a call. It would be nice to be able to return multiple values like Python can, but again, this has been deemed too difficult. Multiple values can be returned by either ByRef arguments (which are not the default like VB) or returning an object or an array. Unfortunately, this use of "Return" clashes with the "Return" used for a GoSub. I would have preferred a different word for the latter, perhaps "GoBack". The compiler can figure it out, but for readability I think different syntax should have been used. I am a huge fan of GoSubs and consider them one of the things that makes BASICs superior to other languages. Inherent readability being another.

The use of user defined structures is discouraged because I believe they make memory manager tougher, not sure about that though. There is difficulty in matching the packing rules between Gambas definitions and what an underlying language does (like C or FORTRAN external library calls), so structs may not match. I have never heard that it is poor programming practice to use a class when a struct would do. I am curious to what the motivation for that might be or where you have heard it.

Out of curiosity, who is your "community"?

Regards,
Ced
.... and carry a big stick!

User avatar
Quincunxian
Posts: 67
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Quincunxian » Tuesday 13th August 2019 10:46pm

There is a small issue with the Return statement when used with Try/Catch/Finally Error management.
In this example:

Try {some task}
Return {Result}
Finally
{Do some closing task}
Catch
{Handle Error}

In the case of no error occurring, the Return statement works as required but the Finally statement never triggers leaving any 'final' tasks undone. The Function essentially Quits as soon as the Return statement is met.

When you have error trapping in a Function it is better to do this:

Dim ReturnValue as {Required data Type}
Try {some task}
Return Value = {Result}
Finally
{Do some closing task}
Return ReturnValue
Catch
{Handle Error}
Cheers - Quin.
I code therefore I am

Lavos
Posts: 15
Joined: Sunday 28th July 2019 12:22pm

Re: 1st Time User Gambas Questions(Former VB6 user)

Post by Lavos » Wednesday 14th August 2019 10:52am

cogier wrote: ↑
Tuesday 13th August 2019 2:59pm
I have never used structs as Gambas says in capitals 'DON'T USE STRUCTURES, UNLESS YOU HAVE TO!'

What are you trying to acheive? Pehaps we can find an alternative.
Yes, that would be nice! I'll be sure to share when I find something out.
Cedron wrote: ↑
Tuesday 13th August 2019 3:31pm
I've been busy for a little while so I have left this thread alone.

First a general comment for Lavos: I, too, am a long time VB6 (actually VB3-6) user and I found Gambas at the beginning of the year. My impression has been very very favorable. I see Gambas as a big improvement over VB6, sort of like VB done right. I joke it should have been called "Inc VB" (a word play on C++).

Having said that, there are a few things I would have liked to have been done differently. Foremost, is the lack of a line continuation character. I have requested it and it has been deemed too difficult to implement. I hope this is rectified in the future. I do find it a little annoying to have to dim all my variables, I would like to see either type declaration characters used (like VB), or a default type of Integer (instead of Single like orginal BASICs).

Those are the major ones.

Hitting the issues raised in this thread:

I much prefer having "Return (value)" rather than "(function_Name) = (value)" as the way to return values from a call. It would be nice to be able to return multiple values like Python can, but again, this has been deemed too difficult. Multiple values can be returned by either ByRef arguments (which are not the default like VB) or returning an object or an array. Unfortunately, this use of "Return" clashes with the "Return" used for a GoSub. I would have preferred a different word for the latter, perhaps "GoBack". The compiler can figure it out, but for readability I think different syntax should have been used. I am a huge fan of GoSubs and consider them one of the things that makes BASICs superior to other languages. Inherent readability being another.

The use of user defined structures is discouraged because I believe they make memory manager tougher, not sure about that though. There is difficulty in matching the packing rules between Gambas definitions and what an underlying language does (like C or FORTRAN external library calls), so structs may not match. I have never heard that it is poor programming practice to use a class when a struct would do. I am curious to what the motivation for that might be or where you have heard it.

Out of curiosity, who is your "community"?

Regards,
Ced
I'm relieved to see a fellow VB user on this forum, I can relate to your experiences and somewhat understand your opinions of comparing Gambas and VB. To answer your curiosity, people on other programming communities explain tests being done with comparing UDTs vs Classes, UDTs speeds are faster than using Class declarations according to my research from other forums, Jonathan S. Harbour said the same things with his books a while back, I forget which one was that though.

The community? I speak for those who are trying for an alternative to VB, the ones who are transitioning from Microsoft Windows to Linux. It seems like Gambas might be the answer.
Visit me in on my community "here"
Quincunxian wrote: ↑
Tuesday 13th August 2019 10:46pm
There is a small issue with the Return statement when used with Try/Catch/Finally Error management.
In this example:

Try {some task}
Return {Result}
Finally
{Do some closing task}
Catch
{Handle Error}

In the case of no error occurring, the Return statement works as required but the Finally statement never triggers leaving any 'final' tasks undone. The Function essentially Quits as soon as the Return statement is met.

When you have error trapping in a Function it is better to do this:

Dim ReturnValue as {Required data Type}
Try {some task}
Return Value = {Result}
Finally
{Do some closing task}
Return ReturnValue
Catch
{Handle Error}
Thanks for sharing, I'll get right into playing around with this reference.

Post Reply