Error while compiling to library

derez

Expert
Licensed User
Longtime User
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

The code there is:
B4X:
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:
B4X:
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:

derez

Expert
Licensed User
Longtime User
Erel
I declared a type in main:
B4X:
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:
Upvote 0

derez

Expert
Licensed User
Longtime User
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:
Upvote 0

derez

Expert
Licensed User
Longtime User
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
    11.4 KB · Views: 145
  • DirXferlibtest.zip
    135.9 KB · Views: 157
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
Erel
Sorry, the libraries are attached.
You should move the Type declaration to the class.
The Type declaration is at the Tree class globals.
It also seems like the project doesn't reference the TreeView library.
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
    9 KB · Views: 129
Last edited:
Upvote 0
Top