lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I'm a new to Lua and finding its data description features very fascinating.

I decided to use it to document some of our WebLogic configurations.

My data file (wls.data) looks like this (only part of it shown):

Project{
        name = "CCA";
        {
                server = "maxap01",
                IP = "142.27.9.31",
                {
                        domain = "/wlsapp/prod/ivrmax",
                        class = "Production",
                        license = "21345664",
                        JDK = "1.4.2_05",
                        WebLogicVersion = "8.1SP4",
                        Console = "http://142.27.9.31:28041/console/";,
                        {
                                instance = "maximus",
                                port = "28043"
                        }
                }
        },
        {
                server = "maxapp02",
                IP = "142.27.9.34",
                {
                        domain = "/wlsapp/prod/ivrmax",
                        class = "Production",
                        license = "21675756",
                        JDK = "1.4.2_05",
                        WebLogicVersion = "8.1SP4",
                        Console = "http://142.27.9.34:28041/console/";,
                        {
                                instance = "test",
                                port = "28045"
                        },
                        {
                                instance = "maximus",
                                port = "28043"
                        }
                }
        }
}

Project{
        name = "TQ";
        {
                server = "snoopy",
                IP = "142.27.9.31",
                {
                        domain = "/wlsapp/prod/ivrprod",
                        class = "Production",
                        license = "1243064",
                        JDK = "1.4.2_08",
                        WebLogicVersion = "8.1SP5",
                        Console = "http://142.27.9.31:28041/console/";,
                        {
                                instance = "TQ",
                                port = "28043"
                        }
                }
        }
}
==========

And my Lua source file is:

----------------
function Project (table)
        for k,v in pairs(table) do
                if type(v) == "table" then
                        Project(v)
                else
                        print(k,v)
                end
        end
end

dofile("wls.data")
-------------------

I want to convert wls.data to HTML but I haven't added the code to do that yet.  (BTW, is there an
HTML library?).

But my question is: when I run the above Lua script, it correctly reads and prints out the data file, but because of the recursion, the order is not what I wanted:

instance        maximus
port    28043
WebLogicVersion 8.1SP4
Console http://142.27.9.31:28041/console/
JDK     1.4.2_05
class   Production
domain  /wlsapp/prod/ivrmax
license 21345664
IP      142.27.9.31
server  maxap01
instance        test
port    28045
instance        maximus
port    28043
WebLogicVersion 8.1SP4
Console http://142.27.9.34:28041/console/
JDK     1.4.2_05
class   Production
domain  /wlsapp/prod/ivrmax
license 21675756
IP      142.27.9.34
server  maxapp02
name    CCA
instance        TQ
port    28043
WebLogicVersion 8.1SP5
Console http://142.27.9.31:28041/console/
JDK     1.4.2_08
class   Production
domain  /wlsapp/prod/ivrprod
license 1243064
IP      142.27.9.31
server  snoopy
name    TQ

Is there another way I can traverse the table so I can preserve the order as I HTMLize it?

Thanks,

Paul