02 Program block (Chunk)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.