Michael Hartlef
11-03-2008, 22:59
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):
' 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
Here is now the code for plugin1 inside the plugins folder
' Plugin1
function plugin1_Func()
console_writeline("Hello from plugin 1")
end function
And of course, plugin number 2
' Plugin2
function plugin2_Func()
console_writeline("Hello from plugin 2")
console_writeline("Isn't that great? YES!!!!")
end function
It is damn easy. Or?
Cu
Michael
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):
' 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
Here is now the code for plugin1 inside the plugins folder
' Plugin1
function plugin1_Func()
console_writeline("Hello from plugin 1")
end function
And of course, plugin number 2
' Plugin2
function plugin2_Func()
console_writeline("Hello from plugin 2")
console_writeline("Isn't that great? YES!!!!")
end function
It is damn easy. Or?
Cu
Michael