lua-users home
lua-l archive

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


The Doctor wrote:
> I've had a moment of clarity, so I'll describe the idea as I see it.
> I'd write a script, and the finished file (by path/name), either text
> or compiled Lua chunk, would be passed as argument to a single
> executable, with in turn would generate a new executable for testing
> and using, functioning as directed by the script. It would allow
> control over user keyboard input, file access and full control of
> screen print postion so that some rudimentary GUI might be devised
> for a command window.
>
> The ideal would be as easy as:
> MakeLua.exe  Infile.lua  Outfile.exe
>
> The ability to have the 'make' of the final result being this easy is
> of incalculable benefit, given that Lua is intended to make general
> purpose coding fast and easy. It seems such a natural move that I'm
> surprised it's not one of the most established forms Lua has been
> adapted to..

I understand your point of view (hidding Lua in an exe to avoid frightening newbies by the concept) but it hasn't been adopted because in Windows, you can easily "link" Lua files to the interpreter with some tweaks to the registry. On WinNT+, you can even start a Lua program just by typing its name. On Dos-based Win9x, you still have to type "lua foo.lua" (if lua.exe is in the path).
You can also drag a Lua file to the interpreter.

Since there are a number of usable alternatives, nobody felt the need to do the way you want (until now :-) ).

It works fine. I also found, while hunting stuff, a Lua 5 compiled for Windows, which was useful in reporting errors as I fumbled. Lua 5 is a lot different from Lua 4. I missed writeto() and appendto(), but found some nice new ones:

io.write("zoodle\n")
io.output("X.txt")
io.write("wurdle\n")
--io.output(stdout) still haven't worked this one out yet.. :)
io.write("thingit\n")
io.close()

Of course, you can write:
io.write("zoodle\n")
local f = assert(io.open"X.txt")
f:write("wurdle\n")
f:write("thingit\n")
f.close()

A bit sad, maybe, but it sounded better than hello world. >:)
Now all I need to figure out is how to return the flow to stdout, which is a really nice default, btw.

If you prefer the io. way (why not, it is here for that), I would write:
io.write("zoodle\n")
io.output("X.txt")
io.write("wurdle\n")
io.close() -- probably not necessary, but cleaner
io.output(io.stdout) -- you forgot the io. before stdout!
io.write("thingit\n")


This is now good for file splitters, combiners,

See mine below, I wrote it to transfert big files from a Mac to a PC, using floppy disks...

patchers, custom made replacements for TextPad macros,

The SciTE editor as Lua 5.0 scripting <http://www.scintilla.org>. Some other editors too.

> and such, so already a big increase
in power just having this as it is, though that vision I had of a means to address any part of the 25 by 80 characters of a DOS window, and a means to prompt for user input, echoed to screen, while the program runs, and even a bit of colour use in the output to screen, would make an awesome means for fast development in Windows. Colour might sound a tad fancy, but I think it's probably one of the best ways to convey information in a limited space especially in the absense of graphics...

I tried to compile Lua for MS-Dos, to use on an old PC with only this system, but I had a lot of compiler errors. I think that it was because I used an old Dos compiler, which doesn't support modern C syntax.
I went another way, anyway.
Of course, if your goal is to use a Dos box under Windows, a program in console mode is OK.

I believe there is a curses library for Dos, probably using Ansi codes.

--
Philippe Lhoste
--  (near) Paris -- France
--  Professional programmer and amateur artist
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --