lua-users home
lua-l archive

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

Hi Paul,

That sounds great could you mail it to please:

You have raised an interesting point there as well. Lua is designed as an
embedded language but the way it outputs text is not very convenient for
systems which can't trap the standard streams. ie. Windows (unless I'm
missing something). You have to go through the Lua code and alter every
printf, fprintf etc. to redirect the output to your buffer.

What about having a function:  int lua_SendToOutput(FILE* stream, const
char *pBuffer, ...);

Then, all calls to printf in use this (ie. lua_SendToOutput(stdout,...) and
lua_SendToOutput(stderr, ...)). So, if you wanted to trap output you only
have to edit one function in lua to embed it properly in your code. And you
can grab the output of files if you want to check what they are writing....

I think this will work....?

printf("%d %d %d", 1,2,3);
lua_SendToOutput(stdout, "%d %d %d", 1,2,3);

fprintf(stderr, "%d %d %d", 1,2,3);
lua_SendToOutput(stderr, "%d %d %d", 1,2,3);

fprintf(myFile, "%d %d %d", 1,2,3);
lua_SendToOutput(myFile, "%d %d %d", 1,2,3);

void  lua_SendToOutput(FILE* stream, char *fmt, ...)
   char buff[500];
   va_list argp;
   va_start(argp, fmt);
   vsprintf(buff, fmt, argp);

   // This is Lua's default call which I can now edit to redirect the
   // wherever I like.
   fprintf(stream, buff);

e.g. I could alter    fprintf(stream, buff); to
(This sends everything, including files, to my console window).


Paul Bleisch <> on 23/06/98 03:53:15 PM

Please respond to

To:   Multiple recipients of list <>
cc:    (bcc: Nick Trout/UK/PSYGNOSIS)
Subject:  Re: Windows console

Hi Nick,

I have one that is just about ready.  It is very basic.  You can
files on it and it will do_file() them.  (Optionally resetting the
between files.)  There is a single input field for testing things.

As soon as I hook up a Lua print() facility to output to the console it
will be usable.  By default it builds against tklua (no GL) and the
lua library.

It is called WinLua or salt (stupid-ass-lua-tool).

Let me know if this will work for ya.


On Tue, Jun 23, 1998 at 05:53:51AM -0300, wrote:
> Has anyone written a nice Lua Windows console (as opposed to having to
> a DOS prompt) which they would be willing to post on here or point me to
> URL?
> i.e. like the WinPython thing....
> :-)
> Ta,
> Nick.