Form X. is redefined incorrect in Class FMain

Post

Posted
Rating:
#1 (In Topic #577)
Avatar
Trainee
Hello out there,

I am doing my first steps with Gambas 3.14.3 (German language version) on Linux Mint 20.1.

On debugging my source code, I've got the error message "Form X. wird in der Klasse FMain inkorrekt redefiniert"
(which should be translated into English something like "Form X. is redefined incorrect in Class FMain".

What's the cause of this error and - even more important ;-) - how can I fix it?

Thanks a lot
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’
wie wärs mit den source-code? hier ist nämlich niemand  hellseher …

how about the source code? no one here is psychic.


post your project …

Admin note
This is an English language forum, please include a translation when using a different language. Thanks (Vielen Dank)  :D
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’

fox73 said

Hello out there,

I am doing my first steps with Gambas 3.14.3 (German language version) on Linux Mint 20.1.

On debugging my source code, I've got the error message "Form X. wird in der Klasse FMain inkorrekt redefiniert"
(which should be translated into English something like "Form X. is redefined incorrect in Class FMain".

What's the cause of this error and - even more important ;-) - how can I fix it?

Thanks a lot

It should be FMain.X or the name of your Form (or Me.X) not Form.X
Form is used in events like Form_Open() Form_Close() etc but to address the form properties use its name or Me from within it's class

Code (gambas)

  1. Public Sub Form_Open()
  2.   Me.X = 25
  3.   Wait 1
  4.   FMain.X = 50
  5.  

there both Me.X and FMain.X mean the same thing.
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
You can imagine the IDE does this when it creates a default Form (FMain)…

Code (gambas)

  1.  
  2. Public FMain As Form
  3.  
  4. Public Sub Main()
  5.  
  6.     FMain = New Form As "Form"
  7.  
  8.  

So Events will accessed like  Form_EventName()
Properties are accessed with FMain.PropertyName

FMain_Open() will not work but Form_Open() will
Form.Width will not exist but FMain.Width will.

Hope that makes sense.
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Trainee

PJBlack said

wie wärs mit den source-code? hier ist nämlich niemand  hellseher …

how about the source code? no one here is psychic.

Sorry PJBlack. Thought this might would be a typical rookie issue that doesn't need source code to be solved.
And by the way - the entire program has more than 650 lines of code. Should I post 'em all?  :o

Anyway - thanks for your reply!
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Trainee

BruceSteers said

It should be FMain.X or the name of your Form (or Me.X) not Form.X

Hi Bruce and thanks for your replies. In fact, it IS Form.X ! Sorry, but I cannot upload a screenshot to proof.

And - I think I found out the code that causes the error:

I have added the following declaration of a variable

:

Code (gambas)


If set this line to comment, the program runs fine and shows my form  -
I remove the comment attribute - and get the error again …
Is "x" a reserved word in GamBas?
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

fox73 said

BruceSteers said

It should be FMain.X or the name of your Form (or Me.X) not Form.X

Hi Bruce and thanks for your replies. In fact, it IS Form.X ! Sorry, but I cannot upload a screenshot to proof.


yes taking screenshots can be exceptionally complicated.

fox73 said

And - I think I found out the code that causes the error:

I have added the following declaration of a variable

:

Code (gambas)


If set this line to comment, the program runs fine and shows my form  -
I remove the comment attribute - and get the error again …
Is "x" a reserved word in GamBas?

you tell me.
here is the help page
/ - Gambas Documentation
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

fox73 said

…And by the way - the entire program has more than 650 lines of code. Should I post 'em all?…

Hi fox73, when you compose a post on the GambasONE forum, there are 2 tabs below; Options and Attachments.



Image

(Click to enlarge)




If you can zip or compress your project, then you can attach it to your post by using Attachments > Add files.

You can also add your screenshots in a similar way, although these should not be compressed.

Please let us know if you are still having problems with this.

I hope this helps.

SteveDee
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Trainee

stevedee said

If you can zip or compress your project, then you can attach it to your post by using Attachments > Add files.

You can also add your screenshots in a similar way, although these should not be compressed.
SteveDee

Oops, sorry. Didn't see those two buttons. So now here's the screenshot
Image

(Click to enlarge)


As I wrote earlier, omitting the declaration of "x" resolves the problem. So I assume that "x" is a
reserved word in GamBas - is that right?
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
stevedee is in the usergroup ‘Regular’

fox73 said

…omitting the declaration of "x" resolves the problem. So I assume that "x" is a
reserved word in GamBas - is that right?

The error says "Form.X" which would be the X property of a form called Form…which doesn't make sense.

Maybe just copy and paste the section of code that mentions Form.X.
Online now: No Back to the top

Post

Posted
Rating:
#11
Guru
BruceSteers is in the usergroup ‘Guru’
It's best to avoid any declaration names that objects have already.

Internal vars can have a $ prefix so $X will be no problem.

I think the error is that the FMain.class file Inherits Form and all form properties.
So X is already defined in the FMain.class. same applies to all variable names Form has.

Hope that makes sense.
Online now: No Back to the top

Post

Posted
Rating:
#12
Guru
BruceSteers is in the usergroup ‘Guru’

fox73 said

Hello out there,

On debugging my source code, I've got the error message "Form X. wird in der Klasse FMain inkorrekt redefiniert"
(which should be translated into English something like "Form X. is redefined incorrect in Class FMain".



I understand this message now.
Sorry I did not before.
In English it would say
Form.x in incorrectly overridden.

Because using x tried to override the Form.x property (that your FMain.class inherits)
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Trainee

stevedee said

fox73 said

…omitting the declaration of "x" resolves the problem. So I assume that "x" is a
reserved word in GamBas - is that right?

The error says "Form.X" which would be the X property of a form called Form…which doesn't make sense.

Maybe just copy and paste the section of code that mentions Form.X.

I'd like to do, but I can't, as there is  NO Form.X in my source code! Here is, where Form- or Me. are mentioned:

Code (gambas)

  1. Public Sub Form_Open()
  2.    Me.Show  
  3. ...
  4. Public Sub btnEnde_Click()
  5.    Me.Close  

Playing around  I typed "Form." and then scrolled through the properties, if there would be an "X" - and got this message:
Image

(Click to enlarge)


This makes it quite clear to me, why I cannot use a variable "X" - same for "Y"  which is for the top border.

So I would say: "Problem solved - thanks and have a nice Sunday."

Oops - just saw that Bruce already posted the solution. Thanks a lot.
Online now: No Back to the top
1 guest and 0 members have just viewed this.