derez Expert Licensed User Longtime User Feb 1, 2013 #1 Hi I try to compile the TreeView class to a library and get this error: Parsing code. 0.01 Compiling code. 0.02 Compiling generated Java code. Error B4A line: 204 End Sub javac 1.6.0_24 src\dudu\treeview\tree.java:247: package main does not exist main._data _da = null; ^ 1 error Click to expand... The code there is: Code: Sub Node_LongClick(tnode As Node) If SubExists(MyModule,"NodeLongClicked") Then CallSubDelayed3(MyModule,"NodeLongClicked",Me,tnode.TN.tag) End If End Sub MyModule is getting the value of "Me" at initialization from Main activity. An earlier call using MyModule goes without problem: Code: If SubExists(MyModule,"GetData") Then DataList.Initialize CallSub3(MyModule,"GetData",Me,tnode.TN.tag) Else Return End If Except for compilation to library the program runs without problems. The source is here http://www.b4x.com/forum/additional...lass-treeview-class-tree-node.html#post109757 Last edited: Feb 1, 2013
Hi I try to compile the TreeView class to a library and get this error: Parsing code. 0.01 Compiling code. 0.02 Compiling generated Java code. Error B4A line: 204 End Sub javac 1.6.0_24 src\dudu\treeview\tree.java:247: package main does not exist main._data _da = null; ^ 1 error Click to expand... The code there is: Code: Sub Node_LongClick(tnode As Node) If SubExists(MyModule,"NodeLongClicked") Then CallSubDelayed3(MyModule,"NodeLongClicked",Me,tnode.TN.tag) End If End Sub MyModule is getting the value of "Me" at initialization from Main activity. An earlier call using MyModule goes without problem: Code: If SubExists(MyModule,"GetData") Then DataList.Initialize CallSub3(MyModule,"GetData",Me,tnode.TN.tag) Else Return End If Except for compilation to library the program runs without problems. The source is here http://www.b4x.com/forum/additional...lass-treeview-class-tree-node.html#post109757
Erel B4X founder Staff member Licensed User Longtime User Feb 3, 2013 #2 You are somewhere in your code (other than the main module) accessing Main.DATA_DA. This is not allowed in a library as the main module is not available. Upvote 0
You are somewhere in your code (other than the main module) accessing Main.DATA_DA. This is not allowed in a library as the main module is not available.
derez Expert Licensed User Longtime User Feb 3, 2013 #3 Erel I declared a type in main: Code: Type Data(Text As String,Tag As String, btntag As Boolean, ColorSet As Int, bmp As Bitmap,imgdir As String, imgfile As String, imgflag As Int) A variable named "da" is dimmed in sub GetData in main, put into a list which belongs to a node (in Tree class) - the list of all sub-nodes. If I declare the same type in Tree I get an error at compilation, saying that it was already declared. If I use the declaration in main, I can dim a variable in tree and it compiles. So you are saying that the library cannot use a type from main, how can I still use such a type in the class ? If I declare it as another type I will not be able to read it from the list. Is there a way to declare the type in the class and use this type by main ? My first implementation to pass the data was a comma_separated string but the use of a type is much nicer. Last edited: Feb 3, 2013 Upvote 0
Erel I declared a type in main: Code: Type Data(Text As String,Tag As String, btntag As Boolean, ColorSet As Int, bmp As Bitmap,imgdir As String, imgfile As String, imgflag As Int) A variable named "da" is dimmed in sub GetData in main, put into a list which belongs to a node (in Tree class) - the list of all sub-nodes. If I declare the same type in Tree I get an error at compilation, saying that it was already declared. If I use the declaration in main, I can dim a variable in tree and it compiles. So you are saying that the library cannot use a type from main, how can I still use such a type in the class ? If I declare it as another type I will not be able to read it from the list. Is there a way to declare the type in the class and use this type by main ? My first implementation to pass the data was a comma_separated string but the use of a type is much nicer.
derez Expert Licensed User Longtime User Feb 3, 2013 #4 I don't know why it didn't work this way on the first time I tried it but now it works: The Type is declared in Tree class and all subs that need this type can declare variables of it, both in the class and in the main activity. Now it also compiles to a library. Erel, I think that your compiler has a soul. At first it refuses but if I insist, in the end it agrees... Edit: the library runs only in the demo. Other applications fail, saying that the variable (of the type) is not public in the library. (it shouldn't be public). Last edited: Feb 3, 2013 Upvote 0
I don't know why it didn't work this way on the first time I tried it but now it works: The Type is declared in Tree class and all subs that need this type can declare variables of it, both in the class and in the main activity. Now it also compiles to a library. Erel, I think that your compiler has a soul. At first it refuses but if I insist, in the end it agrees... Edit: the library runs only in the demo. Other applications fail, saying that the variable (of the type) is not public in the library. (it shouldn't be public).
Erel B4X founder Staff member Licensed User Longtime User Feb 4, 2013 #5 Can you upload your project? Upvote 0
derez Expert Licensed User Longtime User Feb 4, 2013 #6 The application used to create the library is linked at the first post. One of those that do not accept it is attached. The library replaces Tree and Node. Attachments TreeViewLib.zip TreeViewLib.zip 11.4 KB · Views: 362 DirXferlibtest.zip DirXferlibtest.zip 135.9 KB · Views: 372 Last edited: Feb 4, 2013 Upvote 0
The application used to create the library is linked at the first post. One of those that do not accept it is attached. The library replaces Tree and Node.
Erel B4X founder Staff member Licensed User Longtime User Feb 5, 2013 #7 Where is the Size and Message libraries? It also seems like the project doesn't reference the TreeView library. About the library compilation issue. You should move the Type declaration to the class. Types declarations are global so you will be able to use this type from any module. Upvote 0
Where is the Size and Message libraries? It also seems like the project doesn't reference the TreeView library. About the library compilation issue. You should move the Type declaration to the class. Types declarations are global so you will be able to use this type from any module.
derez Expert Licensed User Longtime User Feb 9, 2013 #8 Erel Sorry, the libraries are attached. You should move the Type declaration to the class. Click to expand... The Type declaration is at the Tree class globals. It also seems like the project doesn't reference the TreeView library. Click to expand... It doesn't as long as the classes are present as modules, this way the application works. When I replace them with the library I get the error. Tree1 is dimmed as Tree at line 33 of Xfer module. Attachments msg_size.zip msg_size.zip 9 KB · Views: 347 Last edited: Feb 9, 2013 Upvote 0
Erel Sorry, the libraries are attached. You should move the Type declaration to the class. Click to expand... The Type declaration is at the Tree class globals. It also seems like the project doesn't reference the TreeView library. Click to expand... It doesn't as long as the classes are present as modules, this way the application works. When I replace them with the library I get the error. Tree1 is dimmed as Tree at line 33 of Xfer module.
Erel B4X founder Staff member Licensed User Longtime User Feb 10, 2013 #9 Have you tried it with v2.51? I tried it here and it seems to work fine. v2.51 replaced v2.50. You can download it with the same link. Upvote 0
Have you tried it with v2.51? I tried it here and it seems to work fine. v2.51 replaced v2.50. You can download it with the same link.