BASIC

Author Topic: Cross Platform Debug Output  (Read 6299 times)

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2624
    • View Profile
Cross Platform Debug Output
« on: 2011-Aug-22 »
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)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10708
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Cross Platform Debug Output
« Reply #1 on: 2011-Aug-22 »
why inline around stdout?

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2624
    • View Profile
Re: Cross Platform Debug Output
« Reply #2 on: 2011-Aug-22 »
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.
« Last Edit: 2011-Aug-25 by bigsofty »
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)