rttlua newb question: pretty print a table

While trying to interactively debug a lua deployment script, I am
often confronted with tables of strings and integers that do not
pretty print in the shell, so I end up having to address table entries
individually by hand, i.e. silliness like:

> =voltageController:getPortNames()
table: 0x155dde0
> return voltageController:getPortNames() [0]
nil
> return voltageController:getPortNames() [1]
eboxAnalog
> return voltageController:getPortNames() [2]
nil
...

On SO, it sounds like this is just another issue of lua being
barebones to the point of being barely usable interactively:

http://stackoverflow.com/questions/9168058/lua-beginner-table-dump-to-co...

I feel like I'm missing something... anyone know the sane way of
doing this in rttlua?

Cheers,
Andrew

rttlua newb question: pretty print a table

On Do, Nov 28, 2013 at 03:17:41 +0100, Andrew Wagner wrote:
>While trying to interactively debug a lua deployment script, I am
>often confronted with tables of strings and integers that do not
>pretty print in the shell, so I end up having to address table entries
>individually by hand, i.e. silliness like:
>
>> =voltageController:getPortNames()

How about

> =utils.tab2str(voltageController:getPortNames())

?

>table: 0x155dde0
>> return voltageController:getPortNames() [0]
>nil
>> return voltageController:getPortNames() [1]
>eboxAnalog
>> return voltageController:getPortNames() [2]
>nil
>...
>
>On SO, it sounds like this is just another issue of lua being
>barebones to the point of being barely usable interactively:
>
>http://stackoverflow.com/questions/9168058/lua-beginner-table-dump-to-console
>
>I feel like I'm missing something... anyone know the sane way of
>doing this in rttlua?

Markus

Ruben Smits's picture

rttlua newb question: pretty print a table

Hi Andrew,

On Thu, Nov 28, 2013 at 3:17 PM, Andrew Wagner
<andrew [dot] wagner [..] ...> wrote:
> While trying to interactively debug a lua deployment script, I am
> often confronted with tables of strings and integers that do not
> pretty print in the shell, so I end up having to address table entries
> individually by hand, i.e. silliness like:
>
>> =voltageController:getPortNames()
> table: 0x155dde0
>> return voltageController:getPortNames() [0]
> nil
>> return voltageController:getPortNames() [1]
> eboxAnalog
>> return voltageController:getPortNames() [2]
> nil
> ...
>
> On SO, it sounds like this is just another issue of lua being
> barebones to the point of being barely usable interactively:
>
> http://stackoverflow.com/questions/9168058/lua-beginner-table-dump-to-co...
>
> I feel like I'm missing something... anyone know the sane way of
> doing this in rttlua?

Have you considered/tried the following:

http://www.orocos.org/wiki/orocos/toolchain/luacookbook#toc60

Ruben
> Cheers,
> Andrew
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users