F Foz Member Licensed User Longtime User Oct 14, 2011 #1 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?
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?
agraham Expert Licensed User Longtime User Oct 14, 2011 #2 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]
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]
F Foz Member Licensed User Longtime User Jan 16, 2012 #3 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...
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...
Erel B4X founder Staff member Licensed User Longtime User Jan 16, 2012 #4 Can you upload a small project that demonstrates this issue?
F Foz Member Licensed User Longtime User Jan 16, 2012 #5 Sure here are two examples - one works, one doesn't http://shadowtavern.com/test/b4a.zip
Erel B4X founder Staff member Licensed User Longtime User Jan 16, 2012 #6 Thank you. It will be fixed. This error should not stop you, as the modules depend on each other, for now you need to declare the dependent types in the same module.
Thank you. It will be fixed. This error should not stop you, as the modules depend on each other, for now you need to declare the dependent types in the same module.
F Foz Member Licensed User Longtime User Jan 16, 2012 #7 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?
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?
Erel B4X founder Staff member Licensed User Longtime User Jan 16, 2012 #8 Does this mean it will be fixed in the next version? Click to expand... I believe that it will be fixed in the next version.
Does this mean it will be fixed in the next version? Click to expand... I believe that it will be fixed in the next version.
F Foz Member Licensed User Longtime User Mar 27, 2012 #10 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.
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.
J Joe_L Member Licensed User Longtime User Apr 15, 2013 #11 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
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
Erel B4X founder Staff member Licensed User Longtime User Apr 15, 2013 #12 You should write: Code: Copy Dim param As MYTYPE