[BUG] Code Module Variables Not Initialized on Compile to Library

Discussion in 'Bugs & wishlist' started by eelias, Feb 17, 2013.

  1. eelias

    eelias Active Member Licensed User

    I lost hours to find this problem, it was tricky, let me try to explain. All libraries here are based on the compile to library feature.

    I needed to have a way to standardize my source code across many libraries, regarding to consts and types.

    Then I created a library with a code module with the following example:

    Code:
    Sub Process_Globals
       
    'application IDs
       Public cPedidoAppId         As Int = 0
       
    Public cItemAppId         As Int = 1
       
    Public cCaixaAppId         As Int = 2
       
    Public cAgendaAppId         As Int = 3
    End sub
    In a regular application this variables will get initialized with the values and can be used as [codemodule].Valiable

    That was not totally true. I have added this library in many of the libraries that I am creating. The code module is recognized, the variables can referenced, it compile an generate the library just fine.

    However if you add those libraries in apk and run you will find that all these variables are not initialized. THey are all 0

    Then I have added this same library with code module to the main apk, just to declare that and inspect the values of these variables, they showed up correct.

    Then I found the the rest of all other libraries linked to the sema apk are now showing correctly the values as well.

    From my standpoit, it seems that the code module only got the code of process_Globals executed due the reference in the main apk. On the libraries it was not executed, besides the variables were declared.

    My source code is giant to post here to demonstrate this, but it took me hours to discover this weird problem and the workaround.

    I believe this is a bug, since the code module should have the process_globals executed from however is referencing the library it is part of.

    Thank you,

    Eduardo Elias
     
  2. Scantech

    Scantech Active Member Licensed User

    Yes, I have this problem as well. It will be great to have the variables executed, instead of assigning it at the initialize event.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    It sounds like a bug. However I cannot reproduce it. It seems to work fine here.

    Can you reproduce it in a small project?
     
  4. eelias

    eelias Active Member Licensed User

    Do you mind if I send you my project by email so you can take a look?

    The problem is simple to recognize, and I can point it to you, just removing one library from the apk the problem appears.

    Eduardo Elias
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please send it by email.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The issue happens because you haven't referenced all of the user created libraries (that the project depends on).

    If you have two libraries: L1 and L2.
    If L1 depends on L2 then you need to add both libraries to the main project if you want to use L1.
    The compilation succeeds because the compiler adds the jar file of L2 automatically however this isn't enough.

    I agree that it can cause problems as the compiler doesn't throw any error in this case.
     
  7. eelias

    eelias Active Member Licensed User

    Erel,

    Is it possible for the compiler make an automatic internal include in the main project?

    I know you would say to select the libraries, but that implies to know each one that is needed, I am going to have many and many projects, I will need to have a manual control for that.

    And the idea of the library is to hide the code and better organize, so I believe you would agree on that....

    Said that, is it possible to be automatic, with no need to know about that?

    And many thanks on taking a look...
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Such a feature might be added in the future. Note that the code is hidden. You only need to know which user libraries are required for your application.
     
Loading...