lua-users home
lua-l archive

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


Hi,

from the user input I get the wanted baudrate as an raw value
- say 
    
    115200.

I have to map this to a constant (in case of luars) which is

    "rs232.RS232_BAUD_115200"

which is a string despite the "." in the middle...

To prevent looping over all constants and forests of if-then-else
stuff (there are more constants to map) I thought, that a table
could do that...

But

    baudrate = { "115200", "rs232.RS232_BAUD_115200" }

and 

    ui=115200
    
gives me another problem:

    baudrate.[ui]
    baudrate.[tostring(ui)]
    baudrate.ui

produces all 'nil' wiith lua -i

How can I map teh user input directly to the constant without
iterating and/or 'if-ing' over dozens of possibilities?

Thank you very much in advance for your help and patience with
a lua newbie... ! :)

Best regards,
mcc