Results 1 to 10 of 10

Thread: Script plugins

  1. #1

    Script plugins

    Hi folks,

    thanks to Eros and his super duper fast development I asked for a feature today at work and now, well see yourself.
    Btw. Eros, I need a new Ferrari. Any chance to have it delivered by the weekend? ;D

    You need the latest release to run this. It's about how to realize script plugins. Here is some sample code (which is attached too):

    [code=thinbasic]

    ' Script plugin sample by Michael Hartlef

    uses "Console"
    uses "File"

    'include %app_sourcepath%+"\plugins\*.tbasicc" <= this does not work,
    #include ".\plugins\*.tbasicc" ' this works

    Dim MyList() As String
    Dim nFiles As Long
    dim i,c as long
    dim funcname as string
    Dim Result As Long

    'Get the list of files inside the plugins folder
    nFiles = DIR_ListArray(MyList, app_scriptpath+"plugins\", "*.tbasicc", %FILE_ADDPATH)

    console_writeline("The plugin directory contains "+nfiles+" files.")
    'Now loop through all the files and call a certain function
    for i = 1 to nFiles
    'Get the function name
    funcname = FILE_PATHSPLIT(mylist(i), %Path_File)+"_Func"
    'Call the function if it does exist
    if function_exists(funcname) then
    console_writeline(crlf+"calling "+funcname+"..."+crlf)
    call funcname to result
    endif
    next

    console_writeline(CRLF+"Press any key...")
    console_waitkey


    [/code]

    Here is now the code for plugin1 inside the plugins folder

    [code=thinbasic]

    ' Plugin1
    function plugin1_Func()
    console_writeline("Hello from plugin 1")
    end function

    [/code]

    And of course, plugin number 2

    [code=thinbasic]

    ' Plugin2
    function plugin2_Func()
    console_writeline("Hello from plugin 2")
    console_writeline("Isn't that great? YES!!!!")
    end function

    [/code]

    It is damn easy. Or?

    Cu
    Michael
    Attached Files Attached Files

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Script plugins

    Quote Originally Posted by Michael Hartlef
    [code=thinbasic]
    'include %app_sourcepath%+"\plugins\*.tbasicc" <= this does not work,
    #include ".\plugins\*.tbasicc" ' this works
    [/code]
    Thanks for the example showing new facilities

    #INCLUDE statement is expanded at pre-parsing time. At that time I've no yet string expression evaluation active so I cannot evaluate the string expression representing the include file. In any case, included files can be specified with relative path as in your example. I will try to improve this behave.

    PS:
    this is for you: http://www.geekologie.com/2007/10/24/ferrari-segway.jpg
    Go slow!
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3

    Re: Script plugins

    Cool, I love these devices. Where is the trunk to store the booze? ;D

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Script plugins

    Michael,

    I was thinking about a version of CALL that automatically executes a FUCNTION_Exists, and if not just jump to next statement (line).
    This should speed up operations when it is not needed to be sure that function really exists.

    What do you think?
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5

    Re: Script plugins

    Sure, allways nice to have. But keep the old call behaviour/function too.

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Script plugins

    Yes, of course.

    Done. New function is: CALL_IFEXISTS FuncNameStringExpression[params, ...] [TO Variable]
    Will be present in next release. If someone have better syntax/name, let me know.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: Script plugins

    No, sounds logical. Keep it.

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

    Re: Script plugins

    Nice stuff,

    it will have very wide use, that is sure. Maybe CALL_IfExists could return TRUE/FALSe value too.
    I will experiment with it tommorow.


    Thanks Eros!,
    Petr
    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

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Script plugins

    Quote Originally Posted by Psch
    Maybe CALL_IfExists could return TRUE/FALSe value too.
    Perfect!
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

    Re: Script plugins

    Wow another incredible request and implementation!! What a great idea!
    You guys are amazing!!
    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

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
  •