Android Question Another Library Question

Gavin

Member
Licensed User
Longtime User
Hello everyone, it"s been a while.
I am teaching my self to use B$XPages and to comply a simple class module to a Library.

I have created two class modules named "Help" and "SizeToFit"
In B$XMainPage, under Class_Globals, I declare the two classes,

Class declaration:
Sub Class_Globals
    Private BPLHelp    As Help
    Private stf    As SizeToFit

End Sub

Then, under Private Sub B4XPage_Created (Root1 As B4XView), I Initialize the two "instances." (I think that's the correct terminology)
Later, I reference "stf" as shown in the code below

Initialization:
Private Sub B4XPage_Created (Root1 As B4XView)

    BPLHelp.Initialize
    stf.Initialize
    
        lblStart.TextSize = stf.Ideal_Text_Size(lblStart.Text, lblStart, 30, "S")

When I compile and run to my phone, everything works correctly. No errors.
However, when I try to Compile to Library (Alt+5), I receive the following error:-

B4A Version: 12.50
Parsing code. Error
Error parsing program.
Error description: Unknown type: help
Are you missing a library reference?
Error occurred on line: 42 (B4XMainPage)
Private BPLHelpAs Help

I am stumped, that why I am asking for help.
I have tried searching this forum for over a week, but I can not find a simple step by step guide for using Compile to Library.
Also, I have placed #ExcludeFromLibrary:True at the top of BRXMainPage and Help modules.
I know there is B4X.lib, but again, a simple step by step would be helpful, but that's for another thread.

Gavin
 

stevel05

Expert
Licensed User
Longtime User
There are very few good reasons to use Compile to library since b4xlib arrived. I would suggest that you concentrate your initial efforts with b4xlib.

But to try to answer your question.

you say :

Also, I have placed #ExcludeFromLibrary:True at the top of BRXMainPage and Help modules.

If you are going to access a module from a library, you cannot exclude it. i.e. The Help module.

If that is not enough to fix it then additionally the error message looks out of place
Private BPLHelpAs Help
There is no space between BPLHelp and As.

Your code has unusual spacing as well

B4X:
Private BPLHelp    As Help
Private stf    As SizeToFit

Replace that with
B4X:
Private BPLHelp As Help
Private stf As sizeToFit
(Space rather than whatever character you have there)

And see if it makes a difference.
 
Last edited:
Upvote 0

Gavin

Member
Licensed User
Longtime User
There are very few good reasons to use Compile to library since b4xlib arrived. I would suggest that you concentrate your initial efforts with b4xlib.

But to try to answer your question.

you say :



If you are going to access a module from a library, you cannot exclude it. i.e. The Help module.

If that is not enough to fix it then additionally the error message looks out of place

There is no space between BPLHelp and As.

Your code has unusual spacing as well

B4X:
Private BPLHelp    As Help
Private stf    As SizeToFit

Replace that with
B4X:
Private BPLHelp As Help
Private stf As sizeToFit
(Space rather than whatever character you have there)

And see if it makes a difference.
Thank you for your quick reply Stevel05.

I tried what you suggested and removed the #ExcludeFromLibrary from the Help Module.
I was then able to Compile to Library.
I tried the library and it Crashed.
As I was about to deleting the library from the Additional Libraries Folder, I notices its size, 174K.
I don't think so.

Finally, I realised what was happening.
I opened a New Default Project and added my existing SizeToFit module only.
Compiled to Library, checked size, 2K, tried, SUCCESS.

It's funny how one can become fixated on a problem. I truly believed that all modules containing #ExcludeFromLibrary, would be exclude from being compiled to the library and only the module I wanted compiled would be.

Anyhow, it appears to be working.
I shall now concentrate on B4Xlib.

Thank You
Gavin
 
Upvote 0
Top