Shop OBEX P1 Docs P2 Docs Learn Events
printing variables in graphics/tv mode — Parallax Forums

printing variables in graphics/tv mode

mosquito56mosquito56 Posts: 387
edited 2008-01-27 02:21 in Propeller 1
I can't find any way to print a variable using the graphics.spin and the tv.spin. Searching and trying things for hours. Just need one line of code or point in the right direction.

Car:=124

gr.text(128,17,string(car))
gr.text(128,17,car))
gr.text(128,17,str(string(car))

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"

······· "No such thing as a dumb question" unless it's on the internet

Technologically challenged individual, Please have pity.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-25 23:45
    Most of the other video drivers have a routine for displaying numbers in decimal and hexadecimal (dec and hex).· These call·the single character output routine of the driver (out).· You could just copy and paste the routine(s) from something like tv_text.spin to graphics.spin and change the out routine calls to whatever graphics needs.· I don't think they refer to anything else.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-25 23:57
    Most people use "Numbers". It looks a little bit terrifying in the beginning, but it it is quite versatile, and not really much code - just many constants smile.gif

    However, lookout for the delayed action of GRAPHICS! Don't re-use the internal string buffer of Numbers as long as the string is still being output!!

    This even fooled Martin once smile.gif

    Post Edited (deSilva) : 1/26/2008 2:04:34 PM GMT
  • VIRANDVIRAND Posts: 656
    edited 2008-01-26 00:02
    Well I think it could be done something like this:

    PUB foo | car
    car:=124

    byte[noparse][[/noparse]@carstring+0]:=(car/100)//10+$30 '30 is ascii for 0 and we display 3 digits here
    byte[noparse][[/noparse]@carstring+1]:=(car/10)//10+$30
    byte[noparse][[/noparse]@carstring+2]:=(car/1)//10+$30
    gr.text(128,17,@carstring)

    DAT
    carstring byte "000",0

    'I think this would display 124. But if car was 99 it would say 099, so add some if's to change leading 0's to $20, spaces.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-26 00:05
    Mike, i have been using out, dec, hex, bin for about a month with vbasic. I tried cut and paste but it didn't work. The out sends it directly to the graphics method but I can't figure out the dx in the printstatement. When i tried dec(123) it print 1,2,3, on top of each other.

    ·I will try it again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······· "What do you mean, it doesn't have any tubes?"

    ······· "No such thing as a dumb question" unless it's on the internet

    Technologically challenged individual, Please have pity.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-26 01:15
    I don't have my Propeller code handy, but you can use "decStr[noparse][[/noparse] p++ ] := digit" instead of "out( digit )" where "p" is initialized to zero at the beginning of "dec" and "decStr" is declared as a 10 byte array. At the end of "dec", you add a zero termination byte with "decStr[noparse][[/noparse] p ] := 0". Now you have a string you can display with gr.text which accounts for the spacing between the characters.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-26 12:38
    Virand: I saw something like this in the pallete demo using Hexstring
    ·hexstring[noparse][[/noparse]0] := hex(co >> 4)
    ·hexstring[noparse][[/noparse]1] := hex(co & $F)
    ·gr.text(8, 19, @colorstring) "Why is this line @colorstring and not @hexstring?
    ·gr.colorwidth(2, 6)
    ·gr.text(1, 19, @colorstring)·· With colorstring defined as "Color" this code ouputs· "Color A3" or whatever the hexcode of the color is under the mouse.
    ··

    ··· I think you've hit on the right idea. I had a bad day yesterday and my brain couldn't figure out how to break a number into individual bytes. LOL. Just divide // and pack the datstring the way I want it to look and off to the races. I feel like going Disco dancing, this is soooo retro. When you get used to OOP kinda hard to go back to the old days.


    ·Mike, I think you came up with the same idea but in a strange language, "English"

    Thanx much guys. I worked on this for hours yesterday.

    P.S. Got it working, now I just need to figure out how to blank the screen to print the updates.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······· "What do you mean, it doesn't have any tubes?"

    ······· "No such thing as a dumb question" unless it's on the internet

    Technologically challenged individual, Please have pity.

    Post Edited (mosquito56) : 1/26/2008 2:47:51 PM GMT
  • VIRANDVIRAND Posts: 656
    edited 2008-01-26 19:55
    My guess is that in the DAT section there is something like this:

    colorstring byte "Color "
    hexstring byte "00",0

    In that case displaying colorstring will also display hexstring.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-27 02:21
    yeah, I got it working fine up to 5 digits now with decimal point. Now to make it generic· with flexable decimal and flexable number of digits.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······· "What do you mean, it doesn't have any tubes?"

    ······· "No such thing as a dumb question" unless it's on the internet

    Technologically challenged individual, Please have pity.
Sign In or Register to comment.