iPhone DEBUG()

Previous topic - Next topic

bigsofty

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

Regarding IPhone, did you check the xcode debugger with the regular debug command?

bigsofty

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

What? Then I wonder why I got debug output there.

Kitty Hello

stdout also works on windows:

Code (glbasic) Select

IMPORT void __AllocConsole()
__AllocConsole()