0

次の lua スクリプトを使用して、外部 lua ファイルにアクセスして読み取ります。

FileStr = "lariatData-sgeT-2012-05-31.lua"
Hnd, ErrStr = io.open(FileStr, "r")
if Hnd then
    dofile(FileStr)
    for Str in Hnd:lines() do
        print(Str, "\n")
        for exec, val in pairs(sgeT) do
            print(exec.." "..val, "\n")
        end
    end
    Hnd.close()
else
    print(ErrStr, "\n")
end

ただし、exec キーの値が返されると、16 進数のメモリ ロケーションが取得されます。たとえば、1 行の出力は次のようになります。

table: 07x7fdc5b2538f0
4

1 に答える 1

1

以前の質問に答えたように; 関数への再帰呼び出しが必要です。サンプルプログラムはこちらにあります

function DeepPrint (e)
    -- if e is a table, we should iterate over its elements
    if type(e) == "table" then
        for k,v in pairs(e) do -- for every element in the table
            print(k)
            DeepPrint(v)       -- recursively repeat the same procedure
        end
    else -- if not, we can just print it
        print(e)
    end
end
于 2013-04-15T05:06:01.740 に答える