Shop OBEX P1 Docs P2 Docs Learn Events
CONSTANTS - Could someone please explain this to me — Parallax Forums

CONSTANTS - Could someone please explain this to me

idbruceidbruce Posts: 6,197
edited 2011-01-24 12:24 in Propeller 1
llllllllllllllllllllll

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-24 10:26
    Bruce,

    Why not check the Propeller Manual under "Constants"? It's all there. (Hint: It's called an "enumeration".)

    -Phil
  • idbruceidbruce Posts: 6,197
    edited 2011-01-24 10:39
    Phil

    I looked before posting, but couldn't find anything. After your post, I looked again, and found it. Sorry and thank you.

    Bruce
  • Heater.Heater. Posts: 21,230
    edited 2011-01-24 11:16
    idbruce,
    I cannot find any reference to these constants within FullDuplexSerial,
    Perhaps. But maybe they are provide for convenience to be used from the clients of FullDuplexSerial.

    For example LF is the character (byte) value of "Line Feed". In an object using FullDupexSerial it could be used as:
    ser.tx(ser#LF)
    

    Which woul transmit a line feed character down the line.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-24 11:34
    Heater

    I understood their function, I just did not know how or where they were getting their value. As Phil so kindly pointed out, it was all in the Propeller Manual, which explained the enumeration clearly. I just missed finding it when I looked the first time. Did I mention that my eye sight is getting bad? :)

    Thanks for the response Heater
    Bruce
  • Heater.Heater. Posts: 21,230
    edited 2011-01-24 12:03
    Just as well you posed the question.
    I've never noticed they were even in there before and I was defining them again in my own code. Or worse just using the appropriate "magic numbers" here and there.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-24 12:07
    Heater

    This is from the Parallax Serial Terminal example downloaded with Propeller Tool. I modified it a little to suit my liking, but here they are:
    'Parallax Serial Terminal Control Character Constants
      HM =  1 'HM: Home Cursor       
      PC =  2 'PC: Position Cursor In X, Y
      ML =  3 'ML: Move Cursor Left          
      MR =  4 'MR: Move Cursor Right         
      MU =  5 'MU: Move Cursor Up          
      MD =  6 'MD: Move Cursor Down
      BP =  7 'BP: Beep Speaker
      BS =  8 'BS: Backspace
      TB =  9 'TB: Tab
      LF = 10 'LF: Line Feed
      CE = 11 'CE: Clear To End Of line     
      CB = 12 'CB: Clear Lines Below
      CR = 13 'CR: Carriage Return          
      PX = 14 'PX: Position Cursor In X         
      PY = 15 'PY: Position Cursor In Y
      CS = 16 'CS: Clear Screen
      SP = 32 'Space
    

    Cheers
    Bruce
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-24 12:18
    It's too bad there isn't some sort of mechanism to import constants and methods, rather than having to refer to them as sio#LF, sio#CLS, sio.tx, etc. This is something that could be included in the OBJ section, perhaps:
    OBJ
    
      sio : "FullDuplexSerial" CR, LF, CLS, tx, rx, dec
    

    Even a using pragma would be helpful for including an object's namespace in certain sections of code.

    -Phil
  • idbruceidbruce Posts: 6,197
    edited 2011-01-24 12:24
    Phil

    I know you said you don't like autoupdates, but it sure would be nice that if you declared a FDS object that a message box would pop up asking you if you would like to add FDS constants to the current file :)

    Bruce
Sign In or Register to comment.