Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, you are probably up against a known deficiency in the <code>print()</code> function, which is really intended for quick and dirty debugging at a console prompt, and is missing some necessary flexibility.</p> <p>The base library function <code>print()</code> implemented by <a href="http://www.lua.org/source/5.1/lbaselib.c.html#luaB_print" rel="noreferrer"><code>luaB_print()</code> in lbaselib.c</a> explicitly uses the C runtime's <code>stdout</code> stream as its destination. Since it refers to the global variable <code>stdout</code> explicitly in its implementation, the only way to redirect it is to cause that file handle to be redirected. In a C program that can be done by calling <code>freopen(stdout,...)</code>. Unfortunately, there isn't a stock library function in Lua that can do that.</p> <p>The <code>io</code> library is implemented in <a href="http://www.lua.org/source/5.1/liolib.c.html" rel="noreferrer">liolib.c</a>. It uses the function environment to hold a table of open file descriptors, and during its initialization it creates <code>file</code> objects named <code>io.stdin</code>, <code>io.stdout</code> and <code>io.stderr</code> for the three standard descriptors. It also provides functions named <code>io.output</code> and <code>io.input</code> to allow those two descriptors to be modified to point to any open <code>file</code> object (or a newly opened file if a file name is passed). However, those functions only change the function environment table and do not call <code>freopen()</code> to modify the C runtime's table of <code>FILE</code> values.</p> <p>I have no idea how LuaInterface attempts to treat the standard C runtime's idea of <code>stdout</code>. It may very well be that <code>stdout</code> is not connected to anything useful in the VS debugger because it probably takes advantage of some .NET feature to capture output from the module being debugged that may not be all that compatible with C in any case.</p> <p>That said, it is easy to replace the standard <code>print</code> function. Just use existing features of LuaInterface to write a global function named <code>print</code> that calls <code>tostring()</code> on each argument and passes it to the whatever .NET things is the standard output device. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload