Commit c653ca2b authored by capresti's avatar capresti
Browse files

Initial checkin

git-svn-id: http://luainterface.googlecode.com/svn/trunk@2 63eb109e-e254-0410-a61e-ed0b8f8614f5
parent bf05406b
-- an implementation of printf
function printf(...)
io.write(string.format(...))
end
printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date())
-- make global variables readonly
local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end
local g={}
local G=getfenv()
setmetatable(g,{__index=G,__newindex=f})
setfenv(1,g)
-- an example
rawset(g,"x",3)
x=2
y=1 -- cannot redefine `y'
-- the sieve of of Eratosthenes programmed with coroutines
-- typical usage: lua -e N=1000 sieve.lua | column
-- generate all the numbers from 2 to n
function gen (n)
return coroutine.wrap(function ()
for i=2,n do coroutine.yield(i) end
end)
end
-- filter the numbers generated by `g', removing multiples of `p'
function filter (p, g)
return coroutine.wrap(function ()
while 1 do
local n = g()
if n == nil then return end
if math.mod(n, p) ~= 0 then coroutine.yield(n) end
end
end)
end
N=N or 1000 -- from command line
x = gen(N) -- generate primes up to N
while 1 do
local n = x() -- pick a number until done
if n == nil then break end
print(n) -- must be a prime number
x = filter(n, x) -- now remove its multiples
end
-- two implementations of a sort function
-- this is an example only. Lua has now a built-in function "sort"
-- extracted from Programming Pearls, page 110
function qsort(x,l,u,f)
if l<u then
local m=math.random(u-(l-1))+l-1 -- choose a random pivot in range l..u
x[l],x[m]=x[m],x[l] -- swap pivot to first position
local t=x[l] -- pivot value
m=l
local i=l+1
while i<=u do
-- invariant: x[l+1..m] < t <= x[m+1..i-1]
if f(x[i],t) then
m=m+1
x[m],x[i]=x[i],x[m] -- swap x[i] and x[m]
end
i=i+1
end
x[l],x[m]=x[m],x[l] -- swap pivot to a valid place
-- x[l+1..m-1] < x[m] <= x[m+1..u]
qsort(x,l,m-1,f)
qsort(x,m+1,u,f)
end
end
function selectionsort(x,n,f)
local i=1
while i<=n do
local m,j=i,i+1
while j<=n do
if f(x[j],x[m]) then m=j end
j=j+1
end
x[i],x[m]=x[m],x[i] -- swap x[i] and x[m]
i=i+1
end
end
function show(m,x)
io.write(m,"\n\t")
local i=1
while x[i] do
io.write(x[i])
i=i+1
if x[i] then io.write(",") end
end
io.write("\n")
end
function testsorts(x)
local n=1
while x[n] do n=n+1 end; n=n-1 -- count elements
show("original",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort",x)
selectionsort(x,n,function (x,y) return x>y end)
show("after reverse selection sort",x)
qsort(x,1,n,function (x,y) return x<y end)
show("after quicksort again",x)
end
-- array to be sorted
x={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
testsorts(x)
-- make table, grouping all data for the same item
-- input is 2 columns (item, data)
local A
while 1 do
local l=io.read()
if l==nil then break end
local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)$')
if a~=A then A=a io.write("\n",a,":") end
io.write(" ",b)
end
io.write("\n")
-- trace calls
-- example: lua -ltrace-calls bisect.lua
local level=0
local function hook(event)
local t=debug.getinfo(3)
io.write(level," >>> ",string.rep(" ",level))
if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end
t=debug.getinfo(2)
if event=="call" then
level=level+1
else
level=level-1 if level<0 then level=0 end
end
if t.what=="main" then
if event=="call" then
io.write("begin ",t.short_src)
else
io.write("end ",t.short_src)
end
elseif t.what=="Lua" then
-- table.foreach(t,print)
io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">")
else
io.write(event," ",t.name or "(C)"," [",t.what,"] ")
end
io.write("\n")
end
debug.sethook(hook,"cr")
level=0
-- trace assigments to global variables
do
-- a tostring that quotes strings. note the use of the original tostring.
local _tostring=tostring
local tostring=function(a)
if type(a)=="string" then
return string.format("%q",a)
else
return _tostring(a)
end
end
local log=function (name,old,new)
local t=debug.getinfo(3,"Sl")
local line=t.currentline
io.write(t.short_src)
if line>=0 then io.write(":",line) end
io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n")
end
local g={}
local set=function (t,name,value)
log(name,g[name],value)
g[name]=value
end
setmetatable(getfenv(),{__index=g,__newindex=set})
end
-- an example
a=1
b=2
a=10
b=20
b=nil
b=200
print(a,b,c)
-- hex dump
-- usage: lua xd.lua < file
local offset=0
while true do
local s=io.read(16)
if s==nil then return end
io.write(string.format("%08X ",offset))
string.gsub(s,"(.)",
function (c) io.write(string.format("%02X ",string.byte(c))) end)
io.write(string.rep(" ",3*(16-string.len(s))))
io.write(" ",string.gsub(s,"%c","."),"\n")
offset=offset+16
end
LuaInterface License
--------------------
LuaInterface is licensed under the terms of the MIT license reproduced below.
This mean that LuaInterface is free software and can be used for both academic and
commercial purposes at absolutely no cost.
===============================================================================
Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
(end of COPYRIGHT)

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaInterface", "src\LuaInterface\LuaInterface.csproj", "{F55CABBB-4108-4A39-94E1-581FD46DC021}"
ProjectSection(ProjectDependencies) = postProject
{0A82CC4C-9A27-461C-8DB0-A65AC6393748} = {0A82CC4C-9A27-461C-8DB0-A65AC6393748}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaRunner", "src\LuaRunner\LuaRunner.csproj", "{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}"
ProjectSection(ProjectDependencies) = postProject
{0A82CC4C-9A27-461C-8DB0-A65AC6393748} = {0A82CC4C-9A27-461C-8DB0-A65AC6393748}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestLuaInterface", "src\TestLuaInterface\TestLuaInterface.csproj", "{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua511", "..\lua-5.1.2\lua511\lua511.vcproj", "{0A82CC4C-9A27-461C-8DB0-A65AC6393748}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Debug|Win32.ActiveCfg = Debug|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Any CPU.Build.0 = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F55CABBB-4108-4A39-94E1-581FD46DC021}.Release|Win32.ActiveCfg = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Debug|Win32.ActiveCfg = Debug|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Any CPU.Build.0 = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}.Release|Win32.ActiveCfg = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Any CPU.Build.0 = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AEAB974E-4F69-4840-A2C4-7BC55F7C7C3E}.Release|Win32.ActiveCfg = Release|Any CPU
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Debug|Any CPU.ActiveCfg = Debug|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Debug|Mixed Platforms.ActiveCfg = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Debug|Mixed Platforms.Build.0 = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Debug|Win32.ActiveCfg = Debug|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Debug|Win32.Build.0 = Debug|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Release|Any CPU.ActiveCfg = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Release|Mixed Platforms.Build.0 = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Release|Win32.ActiveCfg = Release|Win32
{0A82CC4C-9A27-461C-8DB0-A65AC6393748}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
LuaInterface 2.0.0
------------------
Copyright © 2003-2006 Fabio Mascarenhas de Queiroz
Maintainer: Kevin Hester, kevinh@geeksville.com
lua51.dll and lua51.exe are Copyright © 2005 Tecgraf, PUC-Rio
Getting started with LuaInterface:
---------
* Use LuaRunner.exe to run samples/testluaform.lua
* Run TestLua.exe to see some more test cases
* Look at src/TestLuaInterface/TestLua to see example usage from C#
(optionally run this from inside of the LuaInterface solution in
the debugger). Also provides a good example of how to override .net
methods from Lua and use LuaInterface from within your .net application.
* Look at samples/testluaform.lua to see examples of how to use
.net from inside Lua
* More instructions for installing and using in the doc/guide.pdf file.
What's new in LuaInterface 2.0.1
------------------------------
* Apparently the 2.0 built binaries had an issue for some users, this is just a rebuild with the lua sources pulled into the LuaInterface.zip
What's new in LuaInterface 2.0
------------------------------
* The base lua5.1.2 library is now built as entirely manged code. LuaInterface is now pure CIL
* Various adapters to connect the older x86 version of lua are no longer needed
* Performance fixes contributed by Toby Lawrence, Oliver Nemoz and Craig Presti
What's new in LuaInterface 1.5.3
----------
* Internal lua panics (due to API violations) now throw LuaExceptions into .net
* If .net code throws an exception into Lua and lua does not handle it, the
original exception is forwarded back out to .net land.
* Fix bug in the Lua 5.1.1 gmatch C code - it was improperly assuming gmatch
only works with tables.
What's new in LuaInterface 1.5.2
----------
* Overriding C# methods from Lua is fixed (broken with .net 2.0!)
* Registering static C# functions for Lua is fixed (broken with Lua-5.1.1)
* Rebuilt to fix linking problems with the binaries included in 1.5.1
* RegisterFunction has been leaking things onto the stack
What's new in LuaInterface 1.5.1
----------
Fix a serious bug w.r.t. garbage collection - made especially apparent
with the new lua5.1 switch: If you were *very* unlucky with timing
sometimes Lua would loose track of pointers to CLR functions.
When I added support for static methods, I allowed the user to use either a
colon or a dot to separate the method from the class name. This was not
correct - it broke disambiguation between overloaded static methods.
Therefore, LuaInterface is now more strict: If you want to call a static
method, you must use dot to separate the method name from the class name. Of
course you can still use a colon if an _instance_ is being used.
Static method calls are now much faster (due to better caching).
What's new in LuaInterface 1.5
----------
LuaInterface is now updated to be based on Lua5.1.1. You can either use
your own build/binaries for Lua5.1.1 or use the version distributed here.
(Lots of thanks to Steffen Itterheim for this work!)
LuaInterface.Lua no longer has OpenLibs etc... The base mechanism for
library loading for Lua has changed, and we haven't yet broken appart
the library loading for LuaInterface. Instead, all standard Lua libraries
are automatically loaded at start up.
Fixed a bug where calls of some static methods would reference an
invalid pointer.
Fixed a bug when strings with embedded null characters are passed in or
out of Lua (Thanks to Daniel Néri for the report & fix!)
The native components in LuaInterface (i.e. Lua51 and the loader) are
both built as release builds - to prevent problems loading standard
windows libraries.
Note: You do not need to download/build lua-5.1.1.zip unless you want to
modify Lua internals (a built version of lua51.dll is included in the
regular LuaInterface distribution)
What's New in LuaInterface 1.4
----------
Note: Fabio area of interest has moved off in other directions (hopefully only temporarily).
I've talked with Fabio and he's said he's okay with me doing a new release with various fixes
I've made over the last few months. Changes since 1.3:
Visual Studio 2005/.Net 2.0 is supported.
Compat-5.1 is modified to expect backslash as the path seperator.
LuaInterface will now work correctly with Generic C# classes.
CLR inner types are now supported.
Fixed a problem where sometimes Lua proxy objects would be associated with the wrong CLR object.
If a CLR class has an array accessor, the elements can be accessed using the regular Lua indexing
interface.
Add CLRPackage.lua to the samples directory. This class makes it much easier to automatically
load referenced assemblies. In the next release this loading will be automatic.
To see an quick demonstration of LuaInterface, cd into luainterface/samples and then
type: ..\..\Built\debug\LuaRunner.exe testluaform.lua
Various other minor fixes that I've forgotten. I'll keep better track next time.
Note: LuaInterface is still based on Lua 5.0.2. If someone really wants us to upgrade to Lua 5.1
please send me a note. In the mean time, I'm also distributing a version of
Lua 5.0.2 with an appropriate VS 2005 project file. You do not need to
download this file unless you want to modify Lua internals (a built version
of lua50.dll is included in the regular LuaInterface distribution)
What's New in LuaInterface 1.3
----------
LuaInterface now works with LuaBinaries Release 2 (http://luabinaries.luaforge.net)
and Compat-5.1 Release 3 (http://luaforge.net/projects/compat). The loader DLL is now
called luanet.dll, and does not need a luainterface.lua file anymore
(just put LuaInterface.dll in the GAC, luanet.dll in your package.cpath, and
do require"luanet").
Fixed a bug in the treatment of the char type (thanks to Ron Scott).
LuaInterface.dll now has a strong name, and can be put in the GAC (thanks to Ivan Voras).
You can now use foreach with instances of LuaTable (thanks to Zachary Landau).
There is an alternate form of loading assemblies and importing types (based on an
anonymous contribution in the Lua wiki). Check the _alt files in the samples folder.
What's New in LuaInterface 1.2.1
--------------------------------
Now checks if two LuaInterface.Lua instances are trying to share the same Lua state,
and throws an exception if this is the case. Also included readonly clauses in public
members of the Lua and ObjectTranslator classes.
This version includes the source of LuaInterfaceLoader.dll, with VS.Net 2003 project
files.
What's New in LuaInterface 1.2
------------------------------
LuaInterface now can be loaded as a module, so you can use the lua standalone
interpreter to run scripts. Thanks to Paul Winwood for this idea and sample code
showing how to load the CLR from a C++ program. The module is "luainterface". Make
sure Lua can find luainterface.lua, and LuaInterfaceLoader.dll is either in the
current directory or the GAC. The samples now load LuaInterface as a module, in
its own namespace.
The get_method_bysig, get_constructor_bysig and make_object were changed: now you
pass the *names* of the types to them, instead of the types themselves. E.g:
get_method_bysig(obj,"method","System.String")
instead of
String = import_type("System.String")
get_method_bysig(obj,"method",String)
Make sure the assemblies of the types you are passing have been loaded, or the call
will fail. The test cases in src/TestLuaInterface/TestLua.cs have examples of the new
functions.
LuaRunner -- runs Lua scripts with CLR access
Usage: luarunner <script.lua> [{<arg>}]
---
--- This lua module provides auto importing of .net classes into a named package.
--- Makes for super easy use of LuaInterface glue
---
--- example:
--- Threading = CLRPackage("System", "System.Threading")
--- Threading.Thread.Sleep(100)
local mt = {
--- Lookup a previously unfound class and add it to our table
__index = function(package, classname)
local class = rawget(package, classname)
if class == nil then
class = luanet.import_type(package.packageName .. "." .. classname)
package[classname] = class -- keep what we found around, so it will be shared
end
return class
end
}
--- Create a new Package class
function CLRPackage(assemblyName, packageName)
local table = {}
luanet.load_assembly(assemblyName) -- Make sure our assembly is loaded
-- FIXME - table.packageName could instead be a private index (see Lua 13.4.4)
table.packageName = packageName
setmetatable(table, mt)
return table
end
Some example scripts, showing what LuaInterface can do.
form A simple form, basic event handling
socket Fetches the content of a web site and prints to the
console
testluaform A more complex WinForms example, type some Lua code in
the textbox and run it, or load a Lua script.
-- kevinh - the following lines are part of our standard init
-- require("compat-5.1")
luanet.load_assembly("System.Windows.Forms")
luanet.load_assembly("System.Drawing")
Form=luanet.import_type("System.Windows.Forms.Form")
Button=luanet.import_type("System.Windows.Forms.Button")
Point=luanet.import_type("System.Drawing.Point")
form1=Form()
button1=Button()
button2=Button()
function handleClick(sender,data)
if sender.Text=="OK" then
sender.Text="Clicked"
else
sender.Text="OK"
end
button1.MouseUp:Remove(handler)
print(sender:ToString())
end
button1.Text = "OK"
button1.Location=Point(10,10)
button2.Text = "Cancel"
button2.Location=Point(button1.Left, button1.Height + button1.Top + 10)
handler=button1.MouseUp:Add(handleClick)
form1.Text = "My Dialog Box"
form1.HelpButton = true
form1.MaximizeBox=false
form1.MinimizeBox=false
form1.AcceptButton = button1
form1.CancelButton = button2
form1.Controls:Add(button1)
form1.Controls:Add(button2)
form1:ShowDialog()
--require("compat-5.1")
Forms=luanet.System.Windows.Forms
Form=Forms.Form
Button=Forms.Button
Point=luanet.System.Drawing.Point
form1=Form()
button1=Button()
button2=Button()
function handleClick(sender,data)
if sender.Text=="OK" then
sender.Text="Clicked"
else
sender.Text="OK"
end
button1.MouseUp:Remove(handler)
print(sender:ToString())
end
button1.Text = "OK"
button1.Location=Point(10,10)
button2.Text = "Cancel"
button2.Location=Point(button1.Left, button1.Height + button1.Top + 10)
handler=button1.MouseUp:Add(handleClick)
form1.Text = "My Dialog Box"
form1.HelpButton = true
form1.MaximizeBox=false
form1.MinimizeBox=false
form1.AcceptButton = button1
form1.CancelButton = button2
form1.Controls:Add(button1)
form1.Controls:Add(button2)
form1:ShowDialog()
--require("compat-5.1")
luanet.load_assembly("System")
WebClient=luanet.import_type("System.Net.WebClient")
StreamReader=luanet.import_type("System.IO.StreamReader")
Math=luanet.import_type("System.Math")
print(Math:Pow(2,3))
myWebClient = WebClient()
myStream = myWebClient:OpenRead(arg[1])
sr = StreamReader(myStream)
line=sr:ReadLine()
repeat
print(line)
line=sr:ReadLine()
until not line
myStream:Close()
--require("compat-5.1")
System=luanet.System
WebClient=System.Net.WebClient
StreamReader=System.IO.StreamReader
Math=System.Math
print(Math:Pow(2,3))
myWebClient = WebClient()
myStream = myWebClient:OpenRead(arg[1])
sr = StreamReader(myStream)
line=sr:ReadLine()
repeat
print(line)
line=sr:ReadLine()
until not line
myStream:Close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment