Shop OBEX P1 Docs P2 Docs Learn Events
how to split a long LOOKUP line — Parallax Forums

how to split a long LOOKUP line

ChetChet Posts: 150
edited 2008-09-06 02:02 in General Discussion
I am working on a project that has a 30·entry LOOKUP line.· Given that they are each three digits,·it just makes it hard to print out nicely.

SUB GET_LEVELS:
LOOKUP config, 150, 152, 154, 156, 158, 160, 162, 164, 167, 169, 171, 174, 176, 179, 182,185, 188, 190, 194, 197, 200, 203, 207, 211, 214, 218, 222, 226, 231, 235, 240, tmpB2
RETURN

The line is one long line in the program.

The question is how do you split the line up neatly?

Thanks

Chet

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-09-06 01:31
    You could put the values into a DATA table and use READ. Also, it's considered good practice to define a routine that retursn a value as a function.

    GET_LEVELS      FUNC    1, 1
    



    FUNC GET_LEVELS
      tmpB1 = __PARAM1
    
      IF tmpB1 <= 30 THEN
        READ Levels+tmpB1, tmpB2
      ELSE
        tmpB2 = 0
      ENDIF
      RETURN tmpB2
      ENDFUNC
    



    Levels:
      DATA  150, 152, 154, 156, 158, 160, 162, 164, 167, 169
      DATA  171, 174, 176, 179, 182, 185, 188, 190, 194, 197
      DATA  200, 203, 207, 211, 214, 218, 222, 226, 231, 235
      DATA  240
    


    To use:

    newLevel = GET_LEVEL idx
    
  • ChetChet Posts: 150
    edited 2008-09-06 02:02
    Thanks a lot JM.

    I appreciate your quick reply.

    Chet
Sign In or Register to comment.