From: John L. <jr...@us...> - 2009-06-01 22:28:44
|
Update of /cvsroot/wxlua/wxLua/docs In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9876/wxLua/docs Modified Files: wxlua.html Log Message: Fix running files with spaces in their names. Index: wxlua.html =================================================================== RCS file: /cvsroot/wxlua/wxLua/docs/wxlua.html,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** wxlua.html 28 May 2009 05:49:21 -0000 1.44 --- wxlua.html 1 Jun 2009 22:28:30 -0000 1.45 *************** *** 1,13 **** <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> - - <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> - <title>wxLua Documentation</title> - <meta content="John Labenski" name="author"> ! </head><body> <h2><u>wxLua 2.8.10 - Documentation</u></h2> --- 1,12 ---- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> + <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>wxLua Documentation</title> ! ! ! <meta content="John Labenski" name="author"></head><body> <h2><u>wxLua 2.8.10 - Documentation</u></h2> *************** *** 23,27 **** running standalone wxLua ! scripts (wxLuaFreeze), a Lua module that may be loaded using <i>require("wx")</i> when using the standard Lua executable, and a --- 22,26 ---- running standalone wxLua ! scripts (wxLuaFreeze), a Lua module that may be loaded using <font color="blue"><i>require("wx")</i></font> when using the standard Lua executable, and a *************** *** 38,49 **** fast, dynamic, and easy to learn. Lua contains a limited number of data types, ! mainly numbers, strings, functions, tables, and userdata. Perhaps the most powerful ! feature of the Lua language is that the tables can be used as either ! arrays ! or hash tables that can cross-reference numbers, strings, ! functions, and/or ! subtables.<br> <br> --- 37,46 ---- fast, dynamic, and easy to learn. Lua contains a limited number of data types, ! mainly numbers, booleans, strings, functions, tables, and userdata. Perhaps the most powerful ! feature of the Lua language is that tables can be used as either ! numerically indexed arrays ! or associative arrays that can cross-reference any variable type to any other variable type.<br> <br> *************** *** 145,149 **** <li>wxLua uses an unmodified copy of Lua 5.1.4.</li> ! <li>Official patches on www.lua.org are applied as they are released.<br> </li> --- 142,146 ---- <li>wxLua uses an unmodified copy of Lua 5.1.4.</li> ! <li>However, official patches on www.lua.org are applied as they are released.<br> </li> *************** *** 218,222 **** them with other values or types, there is no "const" keyword.</li> <li>Variables are global unless you put the keyword ! '<i><font color="blue">local</font></i>' in front of them, this is sometimes good practice.</li> <li>The --- 215,219 ---- them with other values or types, there is no "const" keyword.</li> <li>Variables are global unless you put the keyword ! "<i><font color="blue">local</font></i>" in front of them, this is sometimes good practice.</li> <li>The *************** *** 233,237 **** <li>A <i><font color="blue">local</font></i> variable created with the same name as a global ! variable only temporarily supersedes the global.</li> <li>Use the function <font color="blue"><i>type(var_name)</i></font> to --- 230,234 ---- <li>A <i><font color="blue">local</font></i> variable created with the same name as a global ! variable temporarily supersedes the global.</li> <li>Use the function <font color="blue"><i>type(var_name)</i></font> to *************** *** 262,266 **** <li>You can provide an inline alternative to <font color="blue"><i>nil</i></font> ! using the '<i><font color="blue">or</font></i>' keyword since <font color="blue"><i>nil</i></font> evaluates to false.</li> <ul> --- 259,263 ---- <li>You can provide an inline alternative to <font color="blue"><i>nil</i></font> ! using the "<i><font color="blue">or</font></i>" keyword since <font color="blue"><i>nil</i></font> evaluates to false.</li> <ul> *************** *** 278,286 **** <font color="blue"><i>false</i></font>, but the number 0 evaluates as <i><font color="blue">true</font></i> since it has a ! value, i.e. not <font color="blue"><i>nil</i></font>, use <i><font color="blue">"a ~= 0"</font>.</i> </li> </ul> <ul> <li><font color="blue"><i>a = 0; if a ! then print(a) end</i></font> ; prints "0" since the variable '<i>a</i>' evaluates to <i><font color="blue">true</font></i>.</li> --- 275,283 ---- <font color="blue"><i>false</i></font>, but the number 0 evaluates as <i><font color="blue">true</font></i> since it has a ! value, i.e. not <font color="blue"><i>nil</i></font>, use <i><font color="blue">(a ~= 0)</font>.</i> </li> </ul> <ul> <li><font color="blue"><i>a = 0; if a ! then print(a) end</i></font> ; prints "0" since the variable "<i>a"</i> evaluates to <i><font color="blue">true</font></i>.</li> *************** *** 318,321 **** --- 315,321 ---- of a particular string stored at any one time no matter how many variables reference it.</li> + <li>String variables are copy on write and the example above shows that overwriting "b" does not change "a".<br> + </li> + <li><font color="blue"><i>s = "How are 'you'!"</i></font> or <font color="blue"><i>s</i><i> *************** *** 373,379 **** <ul> <li>Printing a table is the same as calling <font color="blue"><i>tostring(t)</i></font> ! on the table which displays the type and its memory address.</li> <li>Assigning a variable to an existing table does not copy the ! table <br> </li> </ul> --- 373,379 ---- <ul> <li>Printing a table is the same as calling <font color="blue"><i>tostring(t)</i></font> ! on the table which displays the variable type and its memory address.</li> <li>Assigning a variable to an existing table does not copy the ! table and you can use either variable to access and modify the elements.<br> </li> </ul> *************** *** 394,400 **** <li>Set values as : <font color="blue"><i>t</i><i>.a = 2; t["a"] = 3; t[10] = 4</i></font></li> ! <li>New ! values that don't already exist are automatically ! created.</li> <li>Clear values by setting them to <i>nil</i>, e.g. <font color="blue"><i>t</i><i>.a = nil</i></font></li> --- 394,399 ---- <li>Set values as : <font color="blue"><i>t</i><i>.a = 2; t["a"] = 3; t[10] = 4</i></font></li> ! <li>Elements are automatically created when assigning new ! values to elements that don't already exist and accessing elements that don't exist returns <font color="blue"><i>nil</i></font>.</li> <li>Clear values by setting them to <i>nil</i>, e.g. <font color="blue"><i>t</i><i>.a = nil</i></font></li> *************** *** 432,436 **** <li>The global table is called <font color="blue"><i>_G</i></font> and you can display it ! as any table using<br> </li> <ul> --- 431,435 ---- <li>The global table is called <font color="blue"><i>_G</i></font> and you can display it ! as you would any table using<br> </li> <ul> *************** *** 451,455 **** function, among other things.</li> <li>This ! is the datatype that wxLua uses wrap wxWidgets C++ objects that are pushed into Lua. <br> </li> --- 450,454 ---- function, among other things.</li> <li>This ! is the data type that wxLua uses wrap wxWidgets C++ objects that are pushed into Lua. <br> </li> *************** *** 468,472 **** <li>prints "function: 01DE2AF8 3 function"</li> <li>Printing a function is the same as calling <font color="blue"><i>tostring(f)</i></font> on the function which displays ! the type and its memory address.</li> </ul> <li>Can --- 467,471 ---- <li>prints "function: 01DE2AF8 3 function"</li> <li>Printing a function is the same as calling <font color="blue"><i>tostring(f)</i></font> on the function which displays ! the variable type and its memory address.</li> </ul> <li>Can *************** *** 493,497 **** functions by value and changes to them do not modify the original.</li> <li>Tables and userdata are passed to functions by reference and ! changes to them modify the original variable.</li> </ul> <ul> --- 492,496 ---- functions by value and changes to them do not modify the original.</li> <li>Tables and userdata are passed to functions by reference and ! changes to them do modify the original variable.</li> </ul> <ul> *************** *** 502,506 **** </li> <li>prints "hello hello", i.e. <font color="blue"><i>tbl</i><i>[1] ! == "hello"</i></font> and the variable <i>item</i> still equals "hello" and was not changed.<br> </li> --- 501,505 ---- </li> <li>prints "hello hello", i.e. <font color="blue"><i>tbl</i><i>[1] ! == "hello"</i></font> and the variable <i>"item"</i> still equals "hello" and was not changed.<br> </li> *************** *** 568,572 **** <blockquote> ! <pre><font color="blue">local a, b, c = 1, 2, 3 -- can assign multiple values<br>a = 1; b = 2; c = 3 -- use ; for multiple lines of code on single line<br>a, b, c = 1, 2, 3 -- this works too<br>if (a == 1) and ((b <= 2) or (c ~= 3)) then <br> print(a+b/c) <br>elseif a == 2 then -- no parentheses necessary<br> print(a)<br>else<br> print(b)<br>end</font></pre> </blockquote> --- 567,571 ---- <blockquote> ! <pre><font color="blue">local a, b, c = 1, 2, 3 -- can assign multiple values<br>a = 1; b = 2; c = 3 -- use ; for multiple lines of code on single line<br>a, b, c = 1, 2, 3 -- this works too<br>if (a == 1) and ((b <= 2) or (c ~= 3)) then <br> print(a+b/c) <br>elseif a == 2 then -- no parentheses necessary<br> print(a)<br>else<br> print(b)<br>end</font></pre> </blockquote> *************** *** 579,583 **** function() ... end</i></font> may be used to simulate one.</li> <blockquote> ! <pre><font color="blue">case = {}<br>case[1] = function() print("Hello #1") end<br>case[2] = function() print("Hello #2") end<br>...<br>if case[value] then<br> case[value]()<br>else<br> print("Unknown case value")<br>end</font></pre> </blockquote> </ul> --- 578,582 ---- function() ... end</i></font> may be used to simulate one.</li> <blockquote> ! <pre><font color="blue">case = {}<br>case[1] = function() print("Hello #1") end -- anonymous function<br>case[2] = function() print("Hello #2") end<br>...<br>if case[value] then<br> case[value]()<br>else<br> print("Unknown case value")<br>end</font></pre> </blockquote> </ul> *************** *** 593,597 **** <blockquote> ! <pre><font color="blue">function Check5(val) if val == 5 then return true end end -- returns nil if val ~= 5<br>local a = 1<br>while a < 10 do<br> print(a)<br> if </font><font><font color="blue">Check5</font></font><font color="blue">(a) then break end<br></font><font><font color="blue"> a = a + 1 -- no increment operator<br></font></font><font color="blue">end</font></pre> </blockquote> --- 592,596 ---- <blockquote> ! <pre><font color="blue">function Check5(val)</font><font><font color="blue"> -- returns nil if val ~= 5</font></font><font color="blue"> <br> if val == 5 then <br> return true <br> end <br>end <br><br>local a = 1<br>while a < 10 do<br> print(a)<br> if </font><font><font color="blue">Check5</font></font><font color="blue">(a) then break end<br></font><font><font color="blue"> a = a + 1 -- no increment operator<br></font></font><font color="blue">end</font></pre> </blockquote> *************** *** 662,666 **** discarded.</li> <li>Return ! values using the '<font color="blue"><i>return</i></font>' keyword.</li> <li>Not all return values need to be used and extra ones will be discarded. </li> --- 661,665 ---- discarded.</li> <li>Return ! values using the "<font color="blue"><i>return</i></font>" keyword.</li> <li>Not all return values need to be used and extra ones will be discarded. </li> *************** *** 722,726 **** <blockquote> ! <pre><font color="blue">-- Print the keys in table t for table of values<br>function PrintKeys(t, vals, cmp_case)<br></font><font><font color="blue"> -- use nested functions for repetitive code or to simplify code<br></font></font><font color="blue"> local function cmp_vals(a, b) <br> if cmp_case then -- using upvalue variable<br> return a == b<br> else<br> return string.lower(a) == string.lower(b)<br> end<br> end<br> <br></font><font color="blue"> local function find_key(t, val)<br> for k,v in pairs(t) do<br> if </font><font><font color="blue">cmp_vals</font></font><font color="blue">(val, v) then return k end<br> end<br> end<br><br> for i = 1, #vals do<br> print(</font><font><font color="blue">find_key(t, vals[i])</font></font><font color="blue">, vals[i])<br> end<br>end<br><br>-- prints "a1 a2", "b1 b2", "nil C2"<br>PrintKeys({a1 = "a2", b1 = "b2", c1 = "c2"}, {"a2", "b2", "C2"}, true)<br><br><br>-- Varargs example, prints "4 4 4 20 20" and "table: 0183B820 10 30 5"<br>function Varargs(...)<br> local args = {...}<br> print(select("#", ...), #{...}, #args, args[2], unpack({...}, 2, 2)) <br> return args, unpack(args) -- same as return ...<br>end<br><br>vals, val1, _, val3 = Varargs(10, 20, 30, 40)<br>print(vals, val1, val3, select("#", Varargs(10, 20, 30, 40)))</font><br></pre> </blockquote> --- 721,725 ---- <blockquote> ! <pre><font color="blue">-- Print the keys in table t for table of values<br>function PrintKeys(t, vals, cmp_case)<br></font><font><font color="blue"> -- use nested functions for repetitive code or to simplify code<br></font></font><font color="blue"> local function cmp_vals(a, b) <br> if cmp_case then -- can use upvalue variables<br> return a == b<br> else<br> return string.lower(a) == string.lower(b)<br> end<br> end<br> <br></font><font color="blue"> local function find_key(t, val)<br> for k,v in pairs(t) do<br> if </font><font><font color="blue">cmp_vals</font></font><font color="blue">(val, v) then return k end<br> end<br> end<br><br> for i = 1, #vals do<br> print(</font><font><font color="blue">find_key(t, vals[i])</font></font><font color="blue">, vals[i])<br> end<br>end<br><br>-- prints "a1 a2", "b1 b2", "nil C2"<br>PrintKeys({a1 = "a2", b1 = "b2", c1 = "c2"}, {"a2", "b2", "C2"}, true)<br><br><br>-- Varargs example, prints "4 4 4 20 20" and "table: 0183B820 10 30 5"<br>function Varargs(...)<br> local args = {...}<br> print(select("#", ...), #{...}, #args, args[2], unpack({...}, 2, 2)) <br> return args, unpack(args) -- same as return ...<br>end<br><br>vals, val1, _, val3 = Varargs(10, 20, 30, 40)<br>print(vals, val1, val3, select("#", Varargs(10, 20, 30, 40)))</font><br></pre> </blockquote> *************** *** 781,785 **** in wxLua</u></h2> ! Programming in wxLua means that you're writing Lua programs using the Lua language using an additional table of functions, objects, numbers, --- 780,784 ---- in wxLua</u></h2> ! Programming in wxLua means that you're writing programs in the Lua language using an additional table of functions, objects, numbers, *************** *** 966,977 **** </li> </ul> <li>wxLua ! does not use the static event tables since it is ! not a compiled language. Rather the wxEvtHandler::Connect() function is ! used ! to connect event types to a wxEvtHandler, typically a wxWindow ! derived class. Therefore you do not use EVT_XXX() macros, but the corresponding wxEVT_XXX. The wxluaref.html manual contains a complete ! mapping between the two. </li> <ul> <li>Example : <i>EVT_MENU(id, --- 965,977 ---- </li> </ul> + <li>wxLua ! does not use the static event tables, the EVT_XXX() macros, since it is ! not a compiled language, but rather the corresponding wxEVT_XXX. The wxluaref.html manual contains a complete ! mapping between the two.</li> ! <li>Use the wxEvtHandler::Connect() function to connect event types to a wxEvtHandler, typically a wxWindow ! derived class.</li> ! <ul> <li>Example : <i>EVT_MENU(id, *************** *** 1078,1082 **** stricter about type than Lua. For example; string arguments do not accept numbers which Lua would silently convert. </li> ! <li>Member functions from the base class(es) are also available --- 1078,1082 ---- stricter about type than Lua. For example; string arguments do not accept numbers which Lua would silently convert. </li> ! <li>Member functions inherited from the base class(es) are also available *************** *** 1124,1128 **** that have the %delete binding tag will be eventually garbage collected when they go out of scope.</li> ! <li>Classed without the %delete tag are assumed to be eventually attached to another object that will delete them for you.</li> --- 1124,1128 ---- that have the %delete binding tag will be eventually garbage collected when they go out of scope.</li> ! <li>Classes without the %delete tag are assumed to be eventually attached to another object that will delete them for you.</li> *************** *** 1136,1141 **** <ul> <li>This ! is really a MS Windows problem, in Win95 based systems the number that ! you could create was severely limited, but even in NT systems (XP, Vista) you will have problems if you've created hundreds of them. One visible sign --- 1136,1142 ---- <ul> <li>This ! is really a problem only in MS Windows. Windows 95 based systems are ! allowed only dozens of GDI objects at any one time, but even in NT ! systems (XP, Vista) you will have problems if you've created hundreds of them. One visible sign *************** *** 1149,1153 **** since the Lua userdata that wxLua pushes into Lua only store a void* pointer to the C++ class object, Lua only ! thinks they are of size void* which are on 32bit x86 machines only 8 bytes. However, the class might store a 1024x768 x 3 bytes/pixel --- 1150,1154 ---- since the Lua userdata that wxLua pushes into Lua only store a void* pointer to the C++ class object, Lua only ! thinks they are of size void* which are on 64bit x86 machines only 8 bytes. However, the class might store a 1024x768 x 3 bytes/pixel *************** *** 1160,1165 **** <li>The solution is to use the delete() function on certain types of userdata when you are done.</li> ! <li>Care must be taken to ensure that you're not silently ! creating too many temporary objects.</li> <ul> <li>Example: <i>"wxDC:SetPen(wx.wxPen(wx.wxColour(1,2,3), --- 1161,1166 ---- <li>The solution is to use the delete() function on certain types of userdata when you are done.</li> ! <li><font color="red">Care must be taken to ensure that you're not silently ! creating too many temporary objects.</font></li> <ul> <li>Example: <i>"wxDC:SetPen(wx.wxPen(wx.wxColour(1,2,3), *************** *** 1644,1648 **** The examples below are for MS Windows .exe executables, but the same ! applies for Linux or OSX, just remove the .exe extension for the executable. See also <a href="#wxLua_Applications">wxLua Applications</a> for more information about these programs. --- 1645,1649 ---- The examples below are for MS Windows .exe executables, but the same ! applies for Linux or OSX, just remove the .exe extension from the executable. See also <a href="#wxLua_Applications">wxLua Applications</a> for more information about these programs. *************** *** 1670,1674 **** <li>You may need to adjust the <i>package.cpath</i> variable to have it point to the correct location of the wx.so or ! wx.dll shared library for require("wx") to load.</li> </ul> </ul> --- 1671,1675 ---- <li>You may need to adjust the <i>package.cpath</i> variable to have it point to the correct location of the wx.so or ! wx.dll shared library for <i>require("wx")</i> to load.</li> </ul> </ul> |