简体   繁体   中英

lua attempt to call global write (a nil value)

I get lua error attempt to call global write (a nil value ) if I try to run this program, How to fix this ?

page = [[
<html>
<head>
<title>Practing Lua</title>
<body>
<a href = "http://lua.org"> LUA</a>
</body>
</html>]]
write(page)

write isn't a pre-defined global lua function. you're probably looking for io.write instead?

i suggest reading the lua docs when you're looking for specific functionality from the built-in libraries.

You can't. If write(page) is supposed to output HTML so it appears with links in different color, images visible etc rather than a marked up text, then write must be a function that sends the given text to an HTML renderer, such as a web browser. It is likely that code in your book is using the author's library to write to a web browser. If the author's intention is for you to follow the examples in book, the author likely made this library available from the book's website. Dig in the intro of book.

您可能需要首先包含库文件(该命令可以在您的软件的纪录片中找到。)即

dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM