Page 1 of 3

1st Time User Gambas Questions(Former VB6 user)

Posted: Sunday 28th July 2019 12:32pm
by Lavos
Hello Everyone

I recently got into linux and now im exploring my way through gambas which was the closes thing i could find similar to VB6. I've search the net of ways to translate vb6 Type Statement to Gambas which only uses TypeOF and all i can find are types datatypes unrelated to what im trying to achive. So the question is, how does gambas do things like the way VB6 translates this?

Code: Select all

Public DataStuff as DataStruct

Private Type DataStruct
	a as string
	b as byte
	c as integer
	d as long
End Type
Question 2:
I've started tinkering with "Public Const" stuff and what's got me stumped is that Gambas doesn't like the way this is written.

Code: Select all

Public Const White as byte = 1
Public Const SayColor as byte = White
Is there a logical way of making Gambas understand that "White" is declared as a numeric value?
The error presented as follows: Type Mismatch in modConstants.module:137

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

Posted: Sunday 28th July 2019 2:52pm
by vuott
However, remember that Gambas is not a VB emulation.

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

Posted: Monday 29th July 2019 12:16am
by Quincunxian
Some information from the Gambas Wiki on STRUCT:

http://gambaswiki.org/wiki/lang/structdecl
When using embedded structures, or embedded arrays of structure, the interpreter has to create temporary objects so that you can manipulate them like real objects. And this is slower!
Consequently, DON'T USE STRUCTURES, UNLESS YOU HAVE TO! For example, to communicate with a shared C-library function that requires C structures.
and
If you declare the same structure in two different classes, they must have exactly the same fields, otherwise the interpreter will raise an error.
Personally, I prefer to create a small class now than use a STRUCT as it gives so much more extensibility.

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

Posted: Monday 29th July 2019 5:16am
by Lavos
Quincunxian wrote: Monday 29th July 2019 12:16am Some information from the Gambas Wiki on STRUCT:

http://gambaswiki.org/wiki/lang/structdecl
When using embedded structures, or embedded arrays of structure, the interpreter has to create temporary objects so that you can manipulate them like real objects. And this is slower!
Consequently, DON'T USE STRUCTURES, UNLESS YOU HAVE TO! For example, to communicate with a shared C-library function that requires C structures.
and
If you declare the same structure in two different classes, they must have exactly the same fields, otherwise the interpreter will raise an error.
Personally, I prefer to create a small class now than use a STRUCT as it gives so much more extensibility.
vuott wrote: Sunday 28th July 2019 2:52pm
For the project im doing its actually needed. If you can show me a psuedo code that would help a lot.

Hello,

1st answer:
Public Struct DataStruct
	a As String
	b As Byte
	c As Integer
	d As Long
End
http://gambaswiki.org/wiki/lang/structdecl


2nd answer:
Not variables and only certain native datatypes can be assigned.
http://gambaswiki.org/wiki/lang/constdecl


However, remember that Gambas is not a VB emulation.
Thanks for that, I found this link last minute before I saw this post.

As for the 2nd answer, thats disappointing, would of saved me a lot of time remembering values for calculations. it looks like im going to have to type out long codes everytime i set arguements...

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

Posted: Monday 29th July 2019 5:21am
by Lavos
Quincunxian wrote: Monday 29th July 2019 12:16am Some information from the Gambas Wiki on STRUCT:

http://gambaswiki.org/wiki/lang/structdecl
When using embedded structures, or embedded arrays of structure, the interpreter has to create temporary objects so that you can manipulate them like real objects. And this is slower!
Consequently, DON'T USE STRUCTURES, UNLESS YOU HAVE TO! For example, to communicate with a shared C-library function that requires C structures.
and
If you declare the same structure in two different classes, they must have exactly the same fields, otherwise the interpreter will raise an error.
Personally, I prefer to create a small class now than use a STRUCT as it gives so much more extensibility.
vuott wrote: Sunday 28th July 2019 2:52pm
Hello,

1st answer:
Public Struct DataStruct
	a As String
	b As Byte
	c As Integer
	d As Long
End
http://gambaswiki.org/wiki/lang/structdecl


2nd answer:
Not variables and only certain native datatypes can be assigned.
http://gambaswiki.org/wiki/lang/constdecl


However, remember that Gambas is not a VB emulation.
Thanks for that, I found this link last minute before I saw this post.

As for the 2nd answer, thats disappointing, would of saved me a lot of time remembering values for calculations. it looks like im going to have to type out long codes everytime i set arguements...
For the project im doing its actually needed. If you can show me a psuedo code that would help a lot.

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

Posted: Monday 29th July 2019 7:44am
by Lavos
After exploring much of research into Gambas I came into a conclusion that Gambas isn't ready yet. It's still being updated and is probably close to being up to par with VB6. I'm impressed on how far its went up until now, but it does still lacks some features and support. I'll keep tabs on updates until its ready enough to port my VB6 project over. Its rather a heavy coded project and Gambas still doesn't support some key elements to get it work. It's close but not close enough just yet. Looks like I'll be putting this one down for a bit regrettably. :|

Regards, Lavos

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

Posted: Monday 5th August 2019 5:23am
by Technopeasant
Often Gambas is merely differently implemented than VB, rather than neccesairly feature incomplete, but I can not speak for your project in particular.

If you want a suggestion for another similar IDE for Linux, you may want to look into Lazarus. Very similar RAD environment for building GUI applications, if you are willing to adapt to Pascal.

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

Posted: Saturday 10th August 2019 3:08pm
by Lavos
Technopeasant wrote: Monday 5th August 2019 5:23am Often Gambas is merely differently implemented than VB, rather than neccesairly feature incomplete, but I can not speak for your project in particular.

If you want a suggestion for another similar IDE for Linux, you may want to look into Lazarus. Very similar RAD environment for building GUI applications, if you are willing to adapt to Pascal.
Interesting, I looked up Lazarus and it does look appealing to me. I'll probably play around with it sometime soon.
As for Gambas, I find Gambas Method of Syntax very odd and inflexible, restricted, limited.

Here are some of my baffling examples...
Image

Image

Image

I spent a while reading up on the documentation... it's meh... and the strangest part is having to use an address or key?, to a module or class to call a function or routine.

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

Posted: Sunday 11th August 2019 10:13am
by cogier
Hi Lavos,

The first error you show is caused by you trying to do a 'Dir', which requires a directory, and you are suppling a filename.

Looking at the code you are trying to find if a file exists and the best way to do that is with the 'Exist' command.

You can use &/ to join 2 paths together and you wont have to worry about the slash. The following lines produce the same result:-
Print Exist(User.Home &/ ".bashrc") 
Print Exist(User.Home &/ "/.bashrc")

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

Posted: Sunday 11th August 2019 11:12am
by Lavos
cogier wrote: Sunday 11th August 2019 10:13am Hi Lavos,

The first error you show is caused by you trying to do a 'Dir', which requires a directory, and you are suppling a filename.

Looking at the code you are trying to find if a file exists and the best way to do that is with the 'Exist' command.

You can use &/ to join 2 paths together and you wont have to worry about the slash. The following lines produce the same result:-
Print Exist(User.Home &/ ".bashrc") 
Print Exist(User.Home &/ "/.bashrc")
I've read the documentations about how using exist command works and played around with it before you made this post. It seems to work just fine when i swapped out Dir using File.Dir to see if the file exists.

Do you have any idea why I can't manipulate a Boolean function within its scope?
Image