Types across Code modules

Foz

Member
Licensed User
Longtime User
It appears that it matters in what order Code modules are added when using Types.

Create a new project and then try the following:
Add a code module (mod1)
Add another code module (mod2)
In mod2, in the Process_Globals add
Code: Copy
Type aaa (a As Int)
Go back to mod1, and add
Code: Copy
Type zzz (a as aaa)

Now it won't compile - missing type "aaa".

If you do it the other way around (type aaa in mod1 and zzz in mod2) it works.

Can this be fixed please?
 
There's a related "problem" that may or may not be worth coding against. While the compiler will pick and error duplicate types with different signatures

Code: Copy
[COLOR="Blue"]    Mod1              Mod2
Type a (a As Int)    Type a (b As String)[/COLOR]
It will not error when the type signatures are the same, even if the internal types are different. The compiled code however will always use the first definition that it encountered.

Code: Copy
[COLOR="Blue"]    Mod1                Mod2
Type a (a As Int)    Type a (a As String)[/COLOR]
 
Is there any sort of work around for this problem with the types?

It kinda stops me dead in my tracks when I'm adding custom types further down the line...

If fact, what is causing it to not compile? The resulting java code shouldn't have a problem with it...
 
Thanks - but for clean coding, I prefer to keep my types separate as it's as close to OOP style as I can manage within the restrictions of no OOP. ;)

Does this mean it will be fixed in the next version?
 
Sigh, not fixed yet:
Code: Copy
Compiling code.                         Error
Error parsing program.
Error description: Unknown type: aaa
Are you missing a library reference?
Occurred on line: 6
Type zzz (a As aaa)
I'll hope and pray for the next version.
 
Is this fixed yet or is there a workaround? I need to create a module containing shared code but can't get the existing modules to recognise it.

Code: Copy
'Module SharedStuff
Sub Process_Globals
   Type MYTYPE(a As Int, b As string)
End Sub
'end module sharedstuff

'Activity Uses_SharedStuff
    Private Sub Mysub() 
        Dim param As SharedStuff.MYTYPE
        '.....
    End Sub

Parsing code. Error
Error parsing program.
Error description: Unknown type: sharedstuff
Are you missing a library reference?
Occurred on line: 1228
Dim param As SharedStuff.MYTYPE
 
Back
Top