Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Create table dynamically


Question

Posted

I need your help!

 

I want to create a table like this:

tbl={{text= 'String 1', value='1'},{text= 'String 2', value='2'}}

 

but, I need to do this dynamically during execution, something like this

tbl[1].text="String 1"

tbl[1].value="1"

tbl[2].text="String 2"

tbl[2].value="2"

but I can seem to find the correct syntax for this.

 

Any ideas?

5 answers to this question

Recommended Posts

  • 0
Posted

Please login or register to see this code.

 

  • 0
  • Inquirer
  • Posted

    In your solution, inputPairs is hardcoded.

    I need to create the table without knowing how many text/value combos need to be added in the end. And these values (text and value) are strings in the input data.

    • 0
    Posted (edited)
    8 minutes ago, MiZ said:

    In your solution, inputPairs is hardcoded.

    I need to create the table without knowing how many text/value combos need to be added in the end. And these values (text and value) are strings in the input data.

    You dont need to know how many text/value combos are coming from source..

    Byt the text, and value pairs should come from somewhere...what is the source?

    Edited by Neo Andersson
    • 0
  • Inquirer
  • Posted

    InData.name and InData.id inside a loop.

    • 0
  • Inquirer
  • Posted

    I think I find a solution on the syntax required. Below the inside of the loop:

    dev[cnt]={}
    dev[cnt]={text=""..InData.name.."",value=""..InData.id..""}
    cnt=cnt+1
     

    Thanks for your help!!

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...