Broken Case statement Logic


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    WOW!! I just tried setting my value to 27 manually, and it STILL does not work!!

    Check this out:


    TC1=27


    Select Case TC1
    case 0
    TracID1 = " "
    case TC1 < 27 'A-Z
    TracID1 = TC1 + 64
    case TC1 >= 27 '0-9
    TracID1 = TC1 + 21
    case 37
    TracID1 = ":"
    case 38
    TracID1 = "."
    case else
    TracID1 = "$"
    End Select

    The result is "[", when it should be "0"!!! How could I be setting a value of "27" and having this kind of result?

    TG

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Tom, If you would please try the code exactly as I have written it in my first reply and tell me what the results are.

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Wink

    The answer was to not use the CASE statement at all.. It looked like it was failing somehow internally. So I moved to:

    If TCX = 0 then TracID1 = " "
    If TCX < 27 then TracID1 = TCX+64
    If TCX >=27 then TracID1 = TCX+21
    If TCX = 37 then TracID1 = ":"
    If TCX = 38 then TracID1 = "."
    if TCX > 38 then TracID1 = "$"

    I think the code is smaller, and best of all it works.

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Tom, It only goes to show, There's more than 1 way to skin a cat.......

    Dave Purola,
    N8NTA

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  3. Write Onewire data toa I2C memory / read ASCI
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 16th November 2008, 19:19
  4. Crystalfontz LCD
    By jman12 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 9th February 2007, 15:04
  5. Interrupt/timer not really interrupting...
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd May 2005, 22:05

Members who have read this thread : 0

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