More help on LOOKUP tables please.


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18

    Default More help on LOOKUP tables please.

    Can I put a few LABELS in a lookup table? If yes how can I then use the label returned to make the program GOTO that label? GOTO does not work with a variable.
    Thanks

    Surfies

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Use ON GOTO or ON GOSUB.
    DT

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Do what Darrel says.

    However, if you need to intermix things in a LOOKUP table, then here is a method to achieve that:

    Code:
    lbl_1stPlace CON $FF
    lbl_2ndPlace CON $FE
    lbl_3rdPlace CON $FD
    lbl_4thPlace CON $FC
    My_Index_Var VAR WORD
    MY_LOOKUP_Var VAR WORD
    
    '-----------------------------------------------------------------
    
    LOOKUP My_Index_Var, [1,2, lbl_1stPlace,3,4, lbl_2ndPlace ,5,6, lbl_3rdPlace,7,8, lbl_4thPlace,9,10], MY_LOOKUP_Var
    SELECT CASE MY_LOOKUP_Var
     CASE lbl_1stPlace GOTO 1stPlace
     CASE lbl_2ndPlace GOTO 2ndPlace
     CASE lbl_3rdPlace GOTO 3rdPlace
     CASE lbl_4thPlace GOTO 4thPlace
    END SELECT
    
    '-----------------------------------------------------------------
    1stPlace:
    
    '-----------------------------------------------------------------
    2ndPlace:
    
    '-----------------------------------------------------------------
    3rdPlace:
    
    '-----------------------------------------------------------------
    4thPlace:

  4. #4
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Thanks Darrel and SteveB will try that and let you know.

  5. #5
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    This ON GOTO command, does it work with PBP 2.32 ?? here is part of the code;

    COUNT PORTC.3, 15000, c1 'put pulses in C1

    ON c1 GOTO S1,S2,S3,S4,S5,S6,S7,S8 I get a syntax error on this line, do I miss something? S1 to S8 is labels, C1 is defined as a variable.
    Thanks.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    does it work with PBP 2.32 ???


    Wowwww !!!

    PBP2.32 might be @ least 10 years old ... more than time to upgrade !

    my 2.50 version manual does not show ON GOxxx commands ( appears in the v2.60 manual ), sooo ... prepare your

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Aag ja that explains it.
    thanks for the help and the quick response, nice to have willing clever people on line.
    will just have to make a plan now.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Hi, Surfies

    Could have been much easier for us YOU to explain what you physically tried to do ...

    I smell some kind of overkill trick here

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    There is a push button on portc.3, then depending on how many times its pressed, ( up to 8 times ) the program must then jump to that number's sub routine. I hope that make sense.

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    then depending on how many times its pressed, ( up to 8 times ) the program must then jump to that number's sub routine.
    so ...

    a "basic" set of IF ... THEN ... GOTO is the trick.

    SELECT CASE is the smart way to write it ... but is it available with v 2.32 ???

    LOOKUPx is generally used to retrieve constants/values/strings from a table , not label adresses.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  11. #11
    Join Date
    Jul 2009
    Location
    Worcester South Africa
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: More help on LOOKUP tables please.

    Yes, IF......THEN's is what I'll have to do , thought I could get away without them.
    Thanks a lot for all the help.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts