Shop OBEX P1 Docs P2 Docs Learn Events
Case and ">" spin question — Parallax Forums

Case and ">" spin question

LtechLtech Posts: 380
edited 2015-08-03 14:01 in Propeller 1
I try to shorten a program in spin.

Snipper to build packets out of a variable from 0 to 360
 case atoi(lat,3)                                                               ' 0...360                 >99 :                           addToPacket(DD+0, 1)                          ' Write hundreds IF applicable                             addToPacket(DD+1, 1)                          ' Write tens                           addToPacket(DD+2, 1)                          ' Write ones
               <10 :                           addToPacket(DD+2, 1)                          ' Write ones
               OTHER :                                       addToPacket(DD+1, 1)                          ' Write tens                           addToPacket(DD+2, 1)                          ' Write ones

  But bts compiler did not be lucky about the > and < I try =>

                          :innocent:

Comments

  • For greater than 99, try 100..posx, and less than 10, negx..9.
  • Use ranges (as Chris suggested) -- like this:
      case atoi(lat, 3)    0..9:      addToPacket(DD+2, 1)
        10..99:      addToPacket(DD+1, 1)      addToPacket(DD+2, 1)
        other:      addToPacket(DD+0, 1)       addToPacket(DD+1, 1)       addToPacket(DD+2, 1)
  • Yes, it makes the trick.
    Thank-you
Sign In or Register to comment.