June 23, 2024, 01:44:11 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


How to use LUA with Emergence BASIC

Started by RitchieF, November 15, 2008, 10:20:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RitchieF

Hello all,
did anybody try to use LUA functions in EBASIC ? I am especially interested in the math functions.

I created a lua51.lib from the lua51.dll, the first line in my small tests-prog is :

$USE "C:\Programme\EBDev\libs\lua51.lib" .

A small tool called dllfunc.exe tells me this dll has 123 functions and on the web I found some tuts telling me that the first function for using LUA in my prg must be lua_open().
As much as I understand the tuts this function returns a pointer but I'm unable to get it running.

I define a pointer :

L = pointer

then declare the function :

DECLARE IMPORT,lua_open(),pointer

and try to call the function :

L = lua_open()

and the EBasic linker tells me :

Compiling...
luatest.eba
No Errors

Linking...
Emergence Linker v1.11 Copyright ÂÃ,© 2006 Ionic Wind Software
Unresolved external __imp_lua_open
Error: Unresolved extern __imp_lua_open
Error(s) in linking F:\Ebasic\Lua-Prg\luatest.exe

Can anybody tell me what am I doing wrong.

Any help appreciated. Thanks

Richard

Ionic Wind Support Team

It depends on what language lua was written in.  Try changing the declare:

DECLARE IMPORT,_lua_open(),pointer
L = _lua_open()

Some DLLs written in C/C++ are made incorrectly.  In other words the author doesn't use correct export definitions, and the function names remain "decorated" in the DLL.

Instead of guessing, you can use dependency walker:

http://www.dependencywalker.com/

Besides showing all dll's an executable uses it can show all of the exported function names in a DLL.  I've used it for years and it saves a lot of time. 

Paul.

Ionic Wind Support Team

sapero

Richard,

lua_open is a macro, not a function. Lua is a part of the SDK pak (include files and object file with wrappers) . I remember I have converted four examples for Aurora, and needed to use special manifest file to run my programs.

This macro comes from lua\lua.inc
declare cdecl import, lua_open alias luaL_newstate(),pointer

RitchieF

Hi Paul, hi sapero,

just want to say sorry for this long delay. Thank you for your help. I meanwhile succeded in doing the calculations in EBasic and it works very fast. Don't need LUA for my calculations.(I want to break arcs and circles into lines / CNC related)

Sorry for the delay. Simply forgot this thread

Richard

RitchieF

Hi all,

though I solved my calculations within IWBasic I'd like to know how to use Lua with IWBasic.

I didn't have much success with my code above so I would be happy if anybody could show me a short piece of working code .

Thanks in advance

Richard

sapero

Hello Richard,
I have attached four old examples, and the updated headers for lua.
Create import libraries for lua5.1.dll and lua51.dll if they're missing.

RitchieF

Hi Sapero,

got every sample to work .

Now I have something to play with and study.

Thanks for your help

Richard