--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 25 / Using Custom Build Dll
--
--------------------------------------------------- 
--
-- In this tutorial you will see how to call custom
-- functions from a custom build dll
--
-- Simple dll project is included inside this tutorial directory (mydll)
--
-- You need embedded visual c++ in order to rebuild sample .dll ARM library
-- and visual studio in order to rebuild the X86 library
--
-- Remember! when you use custom dlls, you need two release of each of them:
--
-- ARM version that will be used by your pocketpc
-- X86 version that will be used from Windows 
--
-- Simply add two files inside your External Resources. They must be called as following:
-- ARM_name.dll (ARM version) X86_name.dll (Windows version)
-- For example:
-- ARM_mydll.dll - X86_mydll.dll
--
--------------------------------------------------- 



-- load mydll.dll (note: we remove prefix "arm/x86" when loading it!)
mydll = loadlibrary("mydll.dll")

-- call function "my_cool_dll_function" from a dll, passing 50 and 20 as function paramters
result = execlibrary(mydll, "my_cool_dll_function", 50, 20)

-- free loaded library (this couldn't be necessary, but it's always better 
-- to free resources when they're not needed!
freelibrary(mydll)

function onmainloop()
        
        clear(0,0,0)
        
        print(10, 10, "STRING GOT FROM DLL IS:", 255,0,0)  
        
        -- check if execlibrary call was ok, then print output
        if result ~= false then
                print(10, 40, result, 0,255,0)  
        end
end

function onstylusdown(x,y)
        quit()
end
