Lua parse failing

I have minimised my “run” code to the following to try and work out why I am getting parse failures.

Can someone help, I can’t see the issue?

[code]
for k, v in pairs(luup.devices) do

     local LowChild = 1
     if (k < LowChild) then
      LowChild = k
     end
    end
 </run>[/code]

The above code results in the following in the log file

01 02/06/11 9:57:09.149 LuImplementation::Parse can't parse xml /etc/cmh-ludl//I_Rain8net1.xml <0x400> 01 02/06/11 9:57:09.150 JobHandler_LuaUPnP::ParseAllImplementations failed to parse I_Rain8net1.xml <0x400>

Device files are in XML format.

Characters like “<” and “>” need to be escaped in any code that’s in a Device file, so they make well-formed XML files.

write “<” as “<”
write “>” as “>”

In your example, this “snippet” of the code becomes:

[code]
for k, v in pairs(luup.devices) do

     local LowChild = 1
     if (k &lt; LowChild) then
      LowChild = k
     end
    end
 </run>[/code]

Thanks for clearing that up.

I was working on the premise that I did not need to worry about that between the tags.

Cheers

John

Yeah, that one bites everyone at some time or another. I started using an XML editor a few months back, which has helped a bunch, but I still make the mistake from time to time.

I learned to write my comparisons using greater-than instead of less-than. In XML it isn’t necessary to escape greater-than as > in normal text, so your Lua ends up looking normal.

In the new release version you’ll have the option to put the Lua code in a separate .lua file, so this won’t be a problem anymore.

BTW, I’d recommend to make it possible to put the files into a separate directory for each plugin.

It’s a good idea, we’ll surely consider implementing this.