Shop OBEX P1 Docs P2 Docs Learn Events
TV_Text format question — Parallax Forums

TV_Text format question

Paul_HPaul_H Posts: 85
edited 2007-09-07 22:42 in Propeller 1
Quick question today about the tv_text object.

When the first output to the TV screen is sent without using any locations information, the text appear at the top line of the screen. eg:


  tv.str(string("This is at the top of the screen")




However, when I specify a screen location it is one line below this physical spot. eg:
  tv.str(string($A,5,$B,1))                     'set screen position indent to the 5th column and 1st row.
  tv.str(string("This comes up on the second line")) 




Also the compiler complains when I try to enter a "0" for the line top.
If anyone has the answer, I do appreciate it!
Paul

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-09-07 20:41
    As every self-respecting program TV counts things starting with zero. Thus the upper left corner is (0,0)

    However a funny convention lent from C requires a text (!) string to be terminated by 0, which has nothing to do with the former convention.

    The directive string(...) is aware of the latter convention but not of the former one smile.gif

    So no wonder you get confused. You have to use TV.OUT when zeroes are concerned..

    Post Edited (deSilva) : 9/7/2007 8:48:07 PM GMT
  • Paul_HPaul_H Posts: 85
    edited 2007-09-07 21:31
    Thanks for the clarity, and my program now respects itself wink.gif

    This works:
      tv.out($0A)                                          ' set position on the Zero line at about center scren
      tv.out(19)
      tv.out($0B)
      tv.out(0)
    
      tv.str(string("On the Top Line!"))
    
    



    Gracias!
    Paul
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-07 21:53
    You are welcome!
    I should like to use this opportunity to discuss another rarely used technique:
    Using a "mask" in the DAT section.
    DAT
    myString BYTE 10,19,11
    theLine  BYTE 1
             BYTE "Not on the Top Line", 0
    



    The usage is:
      theLine:= 1
      tv.str(@myString)
    



    Note there still is no cheating with the terminating zero: tv.str will merciless stop at any 0!

    But you can make your own tv_str:
    PRI tv_str(sAddr) ' stringterminator 255 rather than 0
         REPEAT WHILE BYTE[noparse][[/noparse]sAddr]<>255
              tv.out(BYTE[noparse][[/noparse]sAddr++])
    

    Post Edited (deSilva) : 9/7/2007 9:58:58 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-07 22:42
    I just had a look into TV.SPIN, it says there:
        $0A: col := c // cols
        $0B: row := c // rows
    


    So without changing any code at all you could write:

    tv.str(STRING(10, tv#cols, 11, tv#rows, "Upper Left Corner"))

    Post Edited (deSilva) : 9/7/2007 10:47:24 PM GMT
Sign In or Register to comment.