4.3. Lua basic syntax

发布时间 :2023-10-12 23:00:02 UTC      

Lua is very easy to learn, and we can create the first Lua program!

4.3.1. The first Lua program #

Interactive programming #

Lua provides an interactive programming mode. We can enter the program on the command line and see the effect immediately.

Lua interactive programming mode can be realized by command lua -i or lua to enable:

$ lua -i
$ Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
>

On the command line, enter the following command:

> print("Hello World!")

Then we press the enter key and the output is as follows:

> print("Hello World!")
Hello World!
>

Script programming #

We can save the Lua program code to a lua at the end of the file, and execute, this pattern is called scripted programming, such as we store the following code in a file named hello.lua in the script file:

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.