Shop OBEX P1 Docs P2 Docs Learn Events
Outputting PUB items as text to composite out for debugging hydra — Parallax Forums

Outputting PUB items as text to composite out for debugging hydra

Hi Smart People,

I am comfortable with the Arduino IDE, where I can use the serial monitor to output variables for learning/debugging.
I am doing the same with the hydra composite out using itoa(foo,@sbuffer) then gr.text(x,y,@sbuffer) to output some VAR variables from the "VAR" code blocks, but what I really need is to output an x,y from PUB start | i, x,y

There is no doubt something I am missing. Do you have any advice or recommendations in how I can better word the question? I'm stuck.

Thank you for your time.

KB

Comments

  • The way you've provided them, x and y are local variables to the start method (subroutine). You've probably noticed that they're not available outside of the start method, so they're hard to use for debugging. The easiest thing to do is to create a VAR block with x and y like this:

    VAR long x,y
    PUB start | i {, x,y}

    Notice that I've commented out the local variable definitions, but they're in the comment as a reminder. This may not work if there are other uses of x or y in the program.

    With this change, you can display x and y elsewhere in your program.
  • Hi Mr. Green,

    Interesting, so essentially remove x,y from the PUB block and add them to the VAR block if I understand you correctly. I'll give that a go.

    Cheers,

    KB
  • Yes, that makes x and y global variables rather than local (as long as those names aren't used elsewhere). It doesn't automatically make them display somewhere, but you can reference them to display them from somewhere other than your start subroutine.
Sign In or Register to comment.