Results 1 to 4 of 4

Thread: Class Libraries using Oxygen

  1. #1

    Class Libraries using Oxygen

    Class Libraries

    You can now create DLLs containing classes as well as SUBs an Functions. They are declared in much the same way:

    class greeting lib `chatter.dll` alias `greeting`

    followed by the rest of the class header.

    On the library side, the classes must be marked export

    class greeting alias `greeting` export

    If no Alias is specified then the default is a lowercase match for the class name used.

    Internally the methods table is passed from the library to the client at load time. This ensures that new classes can be derived from the the library classes.

    The script below first generates a miinimal class library chatter.dll containing one class with 2 methods. The second parts of the script creates an object with it.


    Oxygen Update: http://community.thinbasic.com/index.php?topic=2517


    [code=thinbasic]
    uses "oxygen","file"
    dim src as string


    '
    '
    '
    ' ###############
    ' ###################
    ' ### ###
    ' ### ### ###
    ' ### ## ## ###
    ' ### ## ## ###
    ' ### ## ## ###
    ' ### ## ## ###
    ' ### ## ## ###
    ' ### #### ## ###
    ' ### #### ###
    ' ### ###
    ' ### ###
    ' #############
    ' #########


    '----------------------
    'GENERATE CLASS LIBRARY
    '======================

    src ="
    #basic

    #file `chatter.dll`

    '-------------------------------------
    class greeting alias `greeting` export
    '=====================================
    method hello(n as string)
    ;
    method goodbye(n as string)
    /
    a as long
    end class


    methods of greeting

    method hello(n as string)
    print `Hello ` n
    end method

    method goodbye(n as string)
    print `Goodbye ` n
    end method

    end methods of greeting



    sub finish()
    terminate
    end sub

    "

    'msgbox 0,o2_prep src
    o2_basic src
    if len(o2_error) then
    msgbox 0, o2_error : stop
    end if
    o2_exec


    ' ##### ###### ###### ###### ######
    ' ######## ######### ######### ######### ###-*-####
    ' ## ## ## ## ## ## ## ## #########
    ' ## ## ## ## ## ## ## ## ##
    ' ## ## ## ## ## ## ## ## ##
    ' ## ## ## ## ## ## ## ## ##
    ' ## ## ## ## ## ## ## ## ##
    ' ## ## ## ## ## ## ## ## ##
    ' ## ########## ########## ########## ##########
    ' # ###### ###### ###### ######
    '

    '----------------------
    'TEST THE CLASS LIBRARY
    '======================

    src="
    #basic
    '------------------------------------------------
    class greeting lib `chatter.dll` alias `greeting`
    '================================================
    method hello(n as string)
    method goodbye(n as string)
    /
    a as long
    end class


    dim g as greeting
    g.goodbye `moon`
    g.hello `earth`

    xit:
    terminate
    "



    file_save ("t.txt",o2_view src )
    'msgbox 0,o2_prep src
    o2_basic src
    if len(o2_error) then
    msgbox 0, o2_error : stop
    end if
    o2_exec
    'msgbox 0,o2_error
    [/code]

  2. #2

    Re: Class Libraries using Oxygen

    Nice, thanks for working further on Oxygen! I plan on using it with my next game which I will be at least prototyping in thinBasic.

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Class Libraries using Oxygen

    Hohoo,

    that is pretty powerful Charles!
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Class Libraries using Oxygen

    Charles, this is really getting exciting, thanks for the news.

    Mike, I will be excited to see what you come up with, good luck on your project!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. Third Party Libraries
    By kryton9 in forum thinBasic General
    Replies: 3
    Last Post: 20-12-2006, 17:40

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •