是否可以为 table 内的所有内容创建一个带有字符串的变量?

Is there a possiblity to create a variable with a string for everything inside of a table?

只是想知道,因为我没有找到解决方案。很确定,因为我是这个 c 的新手:感谢您的帮助。

编辑:为了解释,我将用代码稍微解释一下。

local FileList = fs.list("") --Makes a Table with all the files and directories available (as strings) on the PC it's running on (Inside of a mod called computercraft for minecraft)

for _, file in ipairs(FileList) do 
    --Here I need a function which assigns every string from the table to a variable, just for the explanation I'll call it unknown.function
   
    unknown.function
end 

while true do
    print(a) --a is for example one of the different variables made from the "unknown.function" 
    sleep(1)
end

喜欢这个吗?

AllFiles = {}

function Crazyfunction(file)

 AllFiles[table.getn(AllFiles)+1] = file
 
end

local FileList = fs.list("")

for _, file in ipairs(FileList) do 
    Crazyfunction(file)
end 

while true do
    print(AllFiles[NUMBE_OF_FILE_HERE])
    sleep(1)
end

你的意思是这样?

local FileList = fs.list("")

for _, file in ipairs(FileList) do 
    -- file is the variable which contains a string from the table.
    print(file)
    sleep(1)
end 

你想要的是......你的循环已经完成了。您只是无缘无故地添加了一个额外的循环。