[futurebasic] Simple debugging/logging

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2009 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sun, 8 Nov 2009 17:05:40 +1300
An app that I'm working on needed a simple debugging aid to show  
variable values. Options #1-#3 below didn't quite suit.

[1] Functions in the runtime that give a quick view:
fn DebugString( "some message" )
fn DebugNumber( someValue )
fn DebugRect( theRect )

[2] In-your-face alert from which you can choose to continue or stop:
stop "In fn Bar(), x is " + str$( x )

[3] Logging to Console.app:
DebugStr( "some message" )
CFShow( someCFStringOrOtherCFVariable )

In OS X 10.5, Console.app has a bug that delays the appearance of  
messages for 30--60 s, making it an unattractive option.


[4] The FB Console window was intended as a replacement for the old  
FB4 "lite" runtime, in non-GUI applications. Various examples are in  
FB_5_4_2_Examples > Calculations; see also FB_5_4_2_Examples > Files >  
Serial port tests.

It turns out to make an excellent debug log. All output from 'print'  
goes to the console, where it can be inspected and copied. The output  
can be formatted flexibly.
'-----------
include "ConsoleWindow"
print "some message" tab( 25 );
print "x = " x,  "y = " y
'-----------

This works with most GUI apps (it just appears as an extra window).  
The console copes well with large amounts (100 KB) of text. Its main  
defect until FB 5.4.2 was that it had a stupid name:
include "FBRuntime.incl"

The new not-so-stupid form:
include "ConsoleWindow"
is exactly equivalent.

Robert P.