Shop OBEX P1 Docs P2 Docs Learn Events
String help and the Dat indexing problem — Parallax Forums

String help and the Dat indexing problem

grasshoppergrasshopper Posts: 438
edited 2009-01-10 21:05 in Propeller 1
OBJ
     Ser           : "FullDuplexSerial"
  
Var

  Byte RxDat[noparse][[/noparse]30]                                        ' for serial data buffer
                   
Pub Main 

 Ser.Start(USBRx,USBTx,OFF,19200)
 
  REPEAT         
        IF (ser.rxcheck == "(")                                                                                                                          
                                GetCom
                                                                                               
Pub Getcom | stringCount, Scrap, X
 
  Scrap~
  StringCount~    
                   
  Repeat UNTIL (RxDat[noparse][[/noparse] StringCount ] := SER.rx ) == ")"
          StringCount ++
          
  Repeat X from 1 to 3                             
      IF (textComp(@rxDat[noparse][[/noparse] 0 ],@RX[noparse][[/noparse] X ],7) == TRUE)      
                               
  Case X
    1 : Ser.str(string("One"))
    2 : Ser.str(string("Two"))        
    3 : Ser.str(string("Three"))
                                    
Dat
        RX[noparse][[/noparse] 1 ]           BYTE "One A11",0
        Rx[noparse][[/noparse] 2 ]           BYTE "Two B22",0
        Rx[noparse][[/noparse] 3 ]           BYTE "Three 33",0  




My problem is in the Dat section. I cant index through the library of commands. Is there a way to do this?

Comments

  • grasshoppergrasshopper Posts: 438
    edited 2009-01-10 18:08
    I solved it! Yea
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-01-10 18:48
    So show us what you did.

    -Phil
  • grasshoppergrasshopper Posts: 438
    edited 2009-01-10 20:38
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
     USBRx           = 31         ' Usb comm RX pin
     USBTx           = 30         ' Usb comm TX pin  
     BAUD            = 19200    ' Baud rate   
     Leng = 3                       ' Size of the Table
    
    OBJ                                           
     Ser           : "FullDuplexSerial"
      
    Dat
       Val0       BYTE "D1 XX ?",0     'A string input from computer             
       Val1       BYTE "D1 X1 ?",0     'A string input from computer             
       Val2       BYTE "D1 Y2 S",0         
      Table
            Byte  @Val0, @Val1, @Val2
     
    Var
      Byte RxDat[noparse][[/noparse] 30 ] 
      
    Pub Main 
     Ser.Start(USBRx,USBTx,0,9600)
    
      REPEAT              
          IF (ser.rxcheck == $5B)                                                                                                                          
                                    GetCom
                                                                                                   
    Pub Getcom | stringCount, Scrap ,X 
    
      Scrap~
      StringCount~    
      X := 0         
      Repeat Until (RxDat[noparse][[/noparse] StringCount ] := SER.rx ) == $5D
            StringCount ++
            
      Repeat Leng                                                   
          IF (TextComp(@rxDat[noparse][[/noparse] 0 ],@@Table[noparse][[/noparse] X ],7) == TRUE)
                          quit
          X++
          
      Case X       
          0   : Ser.str(string("[noparse][[/noparse]D1 XX ?]")) 
          1   : Ser.str(string("[noparse][[/noparse]D1 X1 ?]"))
          2   : Ser.str(string("[noparse][[/noparse]D1 Y2 S]")) 
    
    Pub TextComp(stringA,stringB,Count)
    
       Repeat Count
          IF (Byte[noparse][[/noparse]stringA++] <> Byte[noparse][[/noparse]stringB++])
             Return False
       Return True 
                           
    
    



    This is it. Sorry i did not post the code a bit ago, but it did not seem like anyone was interested.

    Post Edited (grasshopper) : 1/10/2009 8:44:57 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-01-10 21:05
    My only suggestion would be to change the Table values (@Val0, et al.) to WORDs instead of BYTEs. You may have lucked out with their offsets being less than 256.

    -Phil
Sign In or Register to comment.