lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Ciao!

As for my previous message on this list I'm working on some source for
using Lua with the PowerBASIC compiler.

Toying around to put it at some practical use, I tought about using Lua
as a macro language for a spreadsheet like application. I used the free
demo version of the excellent Egrid32 from Elias Montoya (a powerfull
grid control for Windows, see here:
http://www.sweetheartgames.com/egrid32.html ) to do some testing.

Then I started modifing one of the samples included.
It turned out to be extremely simple. I just registered the two most basic
function, to get & set cell contents. Then implemented a rough "recalc"
that simply scan cells and if a formula is found (prefixed with "%"),
all is needed to do is strip the first char an execute the string "as
is" with a lua_dostring().

Then, a formula to copy one cell to another will be something like:

> %SetCell(3, 1, GetCell(2, 1))

Or, to fill an entire column with a serie:

> %c = 0; for y = 1, 20, 1  do  c = c + 5; SetCell(3, y, c)  end

Here's a screenshot (17KB):
http://mark0.ngi.it/var/egrid32-luamacro.png

Without much effort, an entire Lua program could be included in a cell!

Hope this could be a useful hint for someone,

Bye!

-- 

Marco Pontello
http://mark0.ngi.it
Home of the TrID file identifier

PowerBLua: http://mark0.ngi.it/code-powerblua-e.html