lua:<表达>预计接近'

发布于 2025-02-11 23:18:00 字数 541 浏览 2 评论 0原文

我的项目是创建一个可以让用户一次打开多个文件夹的脚本,并且用户可以键入他们想要创建文件夹的路径。 这是导致我问题的代码的一部分。

List_length = #Filename

List_next = 1

function Main(Filename)
    for List_next, List_length, List_next in
        do os.execute("mkdir " .. Folderpath.. Slash .. Filename)
        List_next = List_next + 1
    end
        SuscessMSG()
    end

Main(Filename)

问题:

Lua: <expression> expected near 'do'

我不知道问题是什么,我看过Lua关于表达的文档,但我仍然不明白如何解决此错误。

有人可以帮我吗?谢谢。

My project is to create a script that can let user open multiple folder at once, and the user can type the path that they want to create their folders in.
This is the part of the code that cause me problems.

List_length = #Filename

List_next = 1

function Main(Filename)
    for List_next, List_length, List_next in
        do os.execute("mkdir " .. Folderpath.. Slash .. Filename)
        List_next = List_next + 1
    end
        SuscessMSG()
    end

Main(Filename)

Problem:

Lua: <expression> expected near 'do'

I have no idea what is the problem, I have watched the documentation of Lua about expression, and I still don't understand how to solve this error.

Can someone please help me? thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

汹涌人海 2025-02-18 23:18:01

for List_next, List_length, List_next in
        do os.execute("mkdir " .. Folderpath.. Slash .. Filename)
        List_next = List_next + 1
    end

不是有效的LUA代码。

您缺少和do之间的之间的表达式列表。

另外:

Filename = Split(Input_filename, Sep)
 
Filename = io.read("*l")

您要分配一个表格,然后为同一变量分配一个字符串。这将导致进一步的问题。

假设字符串列表t您可以简单地在元素上使用

for _, str in ipairs(t) do
    print(str)
end

This

for List_next, List_length, List_next in
        do os.execute("mkdir " .. Folderpath.. Slash .. Filename)
        List_next = List_next + 1
    end

Is no valid Lua code.

You're missing an expression list between in and do.

Also here:

Filename = Split(Input_filename, Sep)
 
Filename = io.read("*l")

You're assigning a table followed by a string to the same variable. Which will cause further problems.

Assuming a list of strings t you can simply iterate over the elements using

for _, str in ipairs(t) do
    print(str)
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文