[futurebasic] doZen

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2012 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sat, 1 Sep 2012 14:59:53 -0400
compile as "Objective-C"
include "ConsoleWindow"

BeginCDeclaration
CFStringRef doZen();
EndC

BeginCFunction
CFStringRef doZen() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/python"];
[task setArguments:[NSArray arrayWithObjects:@"-c",@"import this",nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
[task release];
NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[result retain];
[pool drain];
return (CFStringRef)result;
}
EndC
toolbox fn doZen = CFStringRef

dim as CFStringRef zen

zen = fn doZen
fn HIViewSetText( sConsoleHITextView, zen )
CFRelease( zen )