Plugin working as include lib / including .lua files / 2 script languages

Posted by Zlad on Sat 14 Mar 2009 01:39 PM — 4 posts, 18,193 views.

#0
Hi there,

I've been doing basic script in VBS and then due to lack of 'Database' commands I built LUA plugin, which I hoped to work as an include library for basic script.

It didn\t work, so my obvious questions are:

1. Is there any posibility to use plugins in the way of includes. So that I am able to call its script functions from basic script?

2. How can I add .lua files as include to main .lua file, just as it was mentioned for VBS and JS in topic:
http://www.gammon.com.au/forum/bbshowpost.php?id=1297

3. Finnaly is it possible to make hybrid script? Which will partly be written in Lua / VBs?

Thanks for feedback
Australia Forum Administrator #1
What do you mean by Database commands?

Version 4.40 added support for accessing SQLite databases from all scripting languages, see:

http://www.gammon.com.au/forum/bbshowpost.php?id=9262


If that is not what you wanted, no you cannot mix languages in a single plugin. Each plugin invokes a particular script engine.

To include Lua files (into a Lua script) just use "dofile" or "require", which are built into Lua.
Amended on Sat 14 Mar 2009 09:02 PM by Nick Gammon
#2
By 'Database commands' i meant *.sqlite database accessing/maintainig functions such as 'DatabaseOpen', 'DatabasePrepare', 'DataColumnValues', etc, which I thought to be only Lua feature.

If I understood your post properly all of these methods are also supproted by other script languages including VBscript... and that makes me a little bit confused.

I didnt really find any VBs examples or notes.

My only goal is to open SQLite db, read/edit values and have the result in VBscript function.


PS. Im not an expert, so you can find some of my statements incorrect.
Australia Forum Administrator #3
Ah, I was just too lazy to do all of the examples documented under the Database* functions in every script language. The syntax in VBscript is pretty similar to Lua (the table handling is a bit different).

For example, here is how you open a database, create a table, and close it, in VBscript:



DatabaseOpen "db", GetInfo (66) & "mytestdb.sqlite", 6  ' open database

'
'  create table
'

DatabaseExec "db", _
"DROP TABLE IF EXISTS weapons;" & _
"CREATE TABLE weapons( " & _
"        weapon_id INTEGER NOT NULL PRIMARY KEY autoincrement," & _
"        name  TEXT NOT NULL," & _
"        damage INT default 10," & _
"        weight REAL" & _
"      );"
      
DatabaseClose "db"  ' close it