Page 2 of 3

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

Posted: Monday 12th August 2019 1:42am
by Quincunxian
Hi Lavos - can you post the code in modDatabase where .FileExist is declared please.

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

Posted: Monday 12th August 2019 7:56am
by Lavos
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-)

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

Posted: Monday 12th August 2019 2:03pm
by cogier
That helped me. :P

Just use: -
Return True
not
.FileExist = True

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

Posted: Monday 12th August 2019 10:32pm
by Quincunxian
Yeah - I don't know how I missed that. *sigh*

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

Posted: Tuesday 13th August 2019 2:55am
by Lavos
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.

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

Posted: Tuesday 13th August 2019 3:11am
by Lavos
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.

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

Posted: Tuesday 13th August 2019 2:59pm
by cogier
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.

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

Posted: Tuesday 13th August 2019 3:31pm
by Cedron
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

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

Posted: Tuesday 13th August 2019 10:46pm
by Quincunxian
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}

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

Posted: Wednesday 14th August 2019 10:52am
by Lavos
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.