[F-Script-talk] Re: How do you print text to the console while running a Cocoa script?
Brought to you by:
pmougin
From: Philippe M. <pm...@ac...> - 2004-02-20 23:20:16
|
The method "log:" in class System can be used to achieve the same=20 effect than a call to NSLog() in Objective-C (i.e., logging a message=20 on stderr) . A predefined instance of System, named "sys" is always=20 defined. Example: sys log: 'scrWidth''s value is ' ++ scrWidth printString Note that NSLog() is used internally by the log: method. -------- F-Script does not define any new API to print something to stdout. You=20= can use the standard Cocoa classes, or roll your own. For instance,=20 using the Cocoa classes: NSFileHandle fileHandleWithStandardOutput writeData:('hello, world'=20 dataUsingEncoding:NSASCIIStringEncoding). This will print "hello, world" to stdout. Best, Philippe Mougin Le 20 f=E9vr. 04, =E0 13:32, Philippe de Rochambeau a =E9crit : > For instance, > > scrWidth :=3D NSScreen mainScreen visibleFrame size width. > scrHeight :=3D NSScreen mainScreen visibleFrame size height. > winWidth :=3D 400. > winHeight :=3D 200. > winX :=3D (scrWidth / 2) - (winWidth / 20). > winY :=3D (scrHeight / 2) - (winHeight / 20). > > 'scrWidth's value is ' ++ scrWidth. "This does not appear on stdout" > > "Instantiate and configure a window" > window :=3D NSWindow alloc initWithContentRect:(winX<>winY=20 > extent:winWidth<>winHeight) > styleMask:NSTitledWindowMask + NSClosableWindowMask+ > NSMiniaturizableWindowMask + NSResizableWindowMask > backing:NSBackingStoreBuffered defer:NO. > > (...) > > the > > 'scrWidth's value is ' ++ scrWidth. command above does not work. > > Many thanks. > > Philippe de Rochambeau |