Fn FBLog() Proof of Concept
Quote from Forum Archives on July 29, 2010, 10:44 amPosted by: kshmidheiser <kshmidheiser@...>
/*Fn FBLog() Proof of Concept
Objective-C offers the NSLog() function
which returns a formatted message
to the Apple System Log facility in the
C printf() function style when passed
format specifiers.Since several of us are developing
in Xcode and FB side-by-side,
I feel FB would benefit from such
a function and offer the following
code as a proof of concept. ( I admit
I have no idea how to use the Apple
System Log outside of Xcode.)A shortcoming of this code is that
it is left to the user to create
and release the resulting CFStringRef.
Also, it would be more user-friendly
as a call rather than a function to
better replicate NSLog().Ideally, this would call the message
window on top of any windows created
within the programmer's FB code.I am submitting this to both the FB
and the FBCocoa lists.Comments welcome.
Ken Shmidheiser
July 29, 2010*/
include "ConsoleWindow"
BeginCCode
CFStringRef FBLog( CFStringRef formatString, ... ) {
CFStringRef resultStr;
va_list argList;va_start (argList, formatString) ;
resultStr = CFStringCreateWithFormatAndArguments(
kCFAllocatorDefault, NULL, formatString, argList );
va_end( argList );
return resultStr;
} // User must release
EndC
toolbox fn FBLog( CFStringRef formatString, ... ) = CFStringRefdim as Double testDouble
dim as CFStringRef testStr
dim as UniChar charStrtestDouble = 123.456789
testStr = @"Hello World!"
charStr = 0x0101testStr = fn FBLog( @"Double: %f
CFStringRef: %@
UniChar accented
a: %C
", testDouble, testStr, charStr )
fn HIViewSetText( sConsoleHITextView, testStr )
CFRelease( testStr )
Posted by: kshmidheiser <kshmidheiser@...>
Fn FBLog() Proof of Concept
Objective-C offers the NSLog() function
which returns a formatted message
to the Apple System Log facility in the
C printf() function style when passed
format specifiers.
Since several of us are developing
in Xcode and FB side-by-side,
I feel FB would benefit from such
a function and offer the following
code as a proof of concept. ( I admit
I have no idea how to use the Apple
System Log outside of Xcode.)
A shortcoming of this code is that
it is left to the user to create
and release the resulting CFStringRef.
Also, it would be more user-friendly
as a call rather than a function to
better replicate NSLog().
Ideally, this would call the message
window on top of any windows created
within the programmer's FB code.
I am submitting this to both the FB
and the FBCocoa lists.
Comments welcome.
Ken Shmidheiser
July 29, 2010
*/
include "ConsoleWindow"
BeginCCode
CFStringRef FBLog( CFStringRef formatString, ... ) {
CFStringRef resultStr;
va_list argList;
va_start (argList, formatString) ;
resultStr = CFStringCreateWithFormatAndArguments(
kCFAllocatorDefault, NULL, formatString, argList );
va_end( argList );
return resultStr;
} // User must release
EndC
toolbox fn FBLog( CFStringRef formatString, ... ) = CFStringRef
dim as Double testDouble
dim as CFStringRef testStr
dim as UniChar charStr
testDouble = 123.456789
testStr = @"Hello World!"
charStr = 0x0101
testStr = fn FBLog( @"Double: %f
CFStringRef: %@
UniChar accented
a: %C
", testDouble, testStr, charStr )
fn HIViewSetText( sConsoleHITextView, testStr )
CFRelease( testStr )