problem compiling with V2

Smee

Well-Known Member
Licensed User
Longtime User
I have this type in 3 different modules

2 are like this
Type RowCol (Row As Int, Col As Int)
in one of them it is as follows

B4X:
   'Cells row,col and key data
   Type RowCol ( Row As Int,Col As Int,Key As Int)

the program compiles in all versions before 2.00 but in 2 I get the error

B4X:
Compiling code.                         Error
Error parsing program.
Error description: An item with the same key has already been added.
Occurred on line: 42
Type RowCol (Row As Int, Col As Int)

I tried to comment 2 of them out but then the compiler does not recognise the type
:confused:
 

Smee

Well-Known Member
Licensed User
Longtime User
Two were declared in Globals one in process

I changed that to globals but it did not fix the problem
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I just did a small test, the type declaration is available to all modules if you declare it in Globals or Process_Globals, you are getting the error because you have changed the signature and added a third parameter.

I seem to remember reading about this somewhere in the recent documentation, but can't find it now.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
yes i changed the names of all 3 declarations and the program compiled. I guess the dim in one module must "run through" all modules now. Have to remember that for future programs
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It's not the dim that is carried over, that will be governed by the normal rules. i.e. in Process_Globals it will be accessible everywhere but cannot involve a type that has Activity objects. In Globals it will be available only in that module.

It is the Type declaration itself that is available everywhere regardless of which globals it is entered in.
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thanks for clarification Steve,

So it is probably better to have a Single Code Module where Types are declared and then they can be accessed by all modules.

Would this be a correct assumption?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
That seems reasonable, or at least make sure you only declare the type once. Whether it's in a separate module or an activity/code module/class that it's most relevant to.

Now of course what I didn't try was to make a type private. That's one for tomorrow I think.

Sent from my HTC Sensation XE with Beats Audio Z715e using Tapatalk 2
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Thanks Erel, I thought that might be the case.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
I had a similar problem last night, but it was because of a duplicated code module, that I didn't use. The previous version, 1.8 compiled the code fine, but 2.0 is a little tighter on the checking. I would check that you haven't got a code module of a different name which declares the variables all over again..

Well that was the error I had and resolved it! :)

HTH
 
Upvote 0
Top