Consecutive statements do not require delimiters, and the lines of code do not have any effect
A=1
B=a*2
is equivalent to
A=1;
B=a*2
Show LUA version information: direct input to Lua in cmd
Exit the LUA Viewer CTRL + Z
In interactive mode, the viewer typically interprets each line of input as a complete block of blocks, and if he checks that the contents of a row are not sufficient to form a complete block, he waits for more content to be entered until all of the content can form a complete block, with this mechanism We can enter the multiline definition of some functions directly in interactive mode, but the more common method is to put the multiline content into a file first, then execute the file in the call Viewer, and if we start the LUA viewer with-I, then the Viewer will enter interactive mode after running the program block.
Lua-i prog means to run the prog block first and then enter interactive mode
Fact.lua
function fact (n)ifn==0 Thenreturn 1 Else returnn * FACT (n1) Endendprint ("Enter a number:") A=io.read ("*number") Print (fact (a)) print ("Enter a number:") A=io.read ("*number") Print (fact (a))*number is a parameter that reads a bunch of numbers to read Lua-I."E:\lua Project\fact.lua"
Call Fact.lua This file
Open cmd Editor input: lua–i "F:\lua Object\fact.lua"
02 Program block (Chunk)