Author Topic: iPhone DEBUG()  (Read 2833 times)

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2640
    • View Profile
iPhone DEBUG()
« on: 2010-Feb-24 »
Simple, replace all your DEBUG() with iDEBUG() and all DEBUG command output will go to the XCode Console window (Under the "Run" menu). When running your program in Windows it will redirect DEBUG back to the normal console output.

Very simple but handy for seeing some output on the running machine.

Code: GLBasic [Select]
// iPhone DEBUG

        FUNCTION iDEBUG: debug$
                ?IFDEF WIN32
                        DEBUG debug$
                ?ELSE
                        INLINE
                        STDOUT(debug_Str);
                        ENDINLINE
                ?ENDIF
        ENDFUNCTION

Use...

Code: GLBasic [Select]
iDEBUG("This is a test!\n")

... it will work on all platforms.


Some Notes:

Thanks to Trucidare for the heads up on STDOUT.

Actually this will send DEBUG output to the GDB Console on any other platform than Windows, handy for Linux/Mac etc...

Not sure how this would perform is STDOUT has been redirected, say for a console program?

I wanted to wrap it all using "?IFDEF GLB_DEBUG" so that I could use the little debug switch, to turn iPhone console output on and off but it seems to be only defined for debugging in WIN32. Maybe Gernot could add this?

Until then you can do it manually if you want all DEBUG output off by wrapping it in your own preprocesser variable, "MY_DEBUG" for example.



Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

MikeHart

  • Guest
Re: iPhone DEBUG()
« Reply #1 on: 2010-Feb-24 »
Regarding IPhone, did you check the xcode debugger with the regular debug command?

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2640
    • View Profile
Re: iPhone DEBUG()
« Reply #2 on: 2010-Feb-24 »
Yes, the normal GLB DEBUG command does not output anything to the console, even with the XCode debugger on.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

MikeHart

  • Guest
Re: iPhone DEBUG()
« Reply #3 on: 2010-Feb-24 »
What? Then I wonder why I got debug output there.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10723
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone DEBUG()
« Reply #4 on: 2010-Feb-24 »
stdout also works on windows:

Code: GLBasic [Select]
IMPORT  void __AllocConsole()
__AllocConsole()