简体   繁体   English

lua尝试调用全局写(零值)

[英]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 ? 如果我尝试运行这个程序,我得到lua错误尝试调用全局写(一个零值),如何解决这个问题?

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. write不是预定义的全局lua函数。 you're probably looking for io.write instead? 你可能正在寻找io.write

i suggest reading the lua docs when you're looking for specific functionality from the built-in libraries. 我建议您在从内置库中寻找特定功能时阅读lua文档

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. 如果write(page)应该输出HTML,那么它会显示不同颜色的链接,图像可见等而不是标记文本,那么write必须是将给定文本发送到HTML渲染器的函数,例如Web浏览器。 It is likely that code in your book is using the author's library to write to a web browser. 您书中的代码可能是使用作者的库来写入Web浏览器。 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");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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