B4J Tutorial In-line Java in multiple modules

Discussion in 'B4J Tutorials' started by Daestrum, May 1, 2015.

  1. Daestrum

    Daestrum Well-Known Member Licensed User

    I have been using the in-line java for ages and only just discovered that you do not have to put all the code in one module, as I was previously doing.
    It can be placed in the module to which it relates to.
    'Me' only refers to the current module.
    Sub inline As JavaObject
    return Me ' the Me of this module
    End Sub
    Running the above for example in Main, would only access the in-line java code inserted into the Main module.
    Each module (either class or code) can have its own inline, that will only run the code in that module.

    Providing each module has an 'inline' sub, you can also run the code from any other module.

    Suppose project has two modules Main and module2 and both have in-line java and inline sub.

    To run the java code in Main from Main module use: inline.RunMethod("xxx",array(yyy))
    To run the java code in module2 from Main module use: module2.inline.RunMethod("aaa",array(bbb))

    This way the in-line java code relating to each module stays with the module, making it easier to maintain.

    Attached is an example with Main module, Code module and Class module.

    Attached Files:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice