Cross Platform Debug Output

Previous topic - Next topic

bigsofty

Small update (better late than never Gernot! :P).

Cross platform debug text output snippet, on iPhone it sends the text to the XCode console debug window for example.

Call InitDebug() at the beginning of your code.

P.S. By using DEBUG() and myDEBUG(), you can output to two separate windows on WIN32, not sure if that's of any use though.

Code (glbasic) Select
// ------------------------------------------ //
//! Initialise Console Window on WIN32
// \param - None
// \preturn - Nothing
// ------------------------------------------ //
FUNCTION InitDebug:
?IFDEF WIN32
IMPORT void __AllocConsole()
__AllocConsole()
?ENDIF
ENDFUNCTION


// ------------------------------------------ //
//! Cross-Platform Debug Text
// \param - None
// \preturn - Nothing
// ------------------------------------------ //
FUNCTION myDEBUG: debug$
    INLINE
         STDOUT(debug_Str);
    ENDINLINE
ENDFUNCTION

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)

Kitty Hello

why inline around stdout?

bigsofty

#2
I honestly cant remember, there was a reason... maybe it pre-dates STDOUT as a command?  :S

The 2nd console window is still handy I suppose though.

P.S. I wrapped the STDOUT so that I could do a quick search and replace for "myDEBUG" to "//myDEBUG" for the final production compilation. Avoiding a mass of extra preprocessing directives for debug mode only or any unnecessary sub calls.
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)