News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Using an SLL for complete application encapsulation.

Started by hutch--, January 26, 2015, 11:55:16 PM

Previous topic - Next topic

hutch--

It is usually good practice in library design to put every function into a separate module as this solves the problem of pulling in unused code but this is essentially the consideration that matters when you build a "component" library. There is in fact another use for the SLL capacity built into the current versions of PB, the capacity to encapsulate entire working applications minus their resources into a single SLL.

Recently I posted a Notepad style editor in the PB API subforum so I don't need to post it here but this is what I used as a test piece to show how you can encapsulate and entire complex object into a single file. This is the source code to call the SLL.

' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    #compile exe "txted.exe"
    #RESOURCE "monotxt.pbr"
    #link "monotxt.sll"

' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

FUNCTION PBmain as LONG

    MonoText

End FUNCTION

' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


In the original source for the text editor there are only 2 mods, changed the PBmain() to the following.

FUNCTION MonoText() COMMON AS LONG


and removed the compiled resource file from the include file as SLLs do not support containing resources.

The exe that calls the SLL does not need header files or any other dependencies, just provide the PBR resource file and the SLL that contains the entire app and it will build directly from the compiler.