Menu

Using a variable to refer to a lookup table

Help
Peter
2015-11-29
2015-12-05
  • Peter

    Peter - 2015-11-29

    Hi,

    It's nearly Christmas so I'm trying to get my light controller up and running again :)

    I have lookup tables for some codes that I need to transmit (Table ON_1, Table ON_2, Table ON_3 etc)

    Can I use a variable in ReadTable to use the table I require i.e. instead of

    ReadTable ON2, i, code

    I would have

    Table2use = "On2"
    ReadTable Table2use, i, code

    I tried the above, but it wouldn't work and I get "Error: Lookup table Table2use not found" when I compile.

     

    Last edit: Peter 2015-11-29
  • Peter

    Peter - 2015-12-05

    Thanks for the reply.

    I couldn't get it to work using strings but it worked OK using numbers. Code posted below in case someone else asks the same question:

    Select Case CMD_TABLE
                Case 1: ReadTable ON_1, i, code
                Case 2: ReadTable ON_2, i, code
                Case 3: ReadTable ON_3, i, code
                Case 4: ReadTable ON_4, i, code
                Case 5: ReadTable OFF_1, i, code
                Case 6: ReadTable OFF_2, i, code
                Case 7: ReadTable OFF_3, i, code
                Case 8: ReadTable OFF_4, i, code
              End Select
    

    Edit: And the lights are working great again!

     

    Last edit: Peter 2015-12-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.