Calendar: Difference between revisions

Content added Content deleted
Line 3,412: Line 3,412:
=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
<lang futurebasic>
<lang futurebasic>
include "ConsoleWindow"


// Legacy version
dim as Str255 a
window 1, @"Calendar", (0, 0, 520, 520 )

Str255 a


open "UNIX", 1,"cal 1969"
open "UNIX", 1,"cal 1969"
do
do
line input #1, a
line input #1, a
print a
print a
until eof(1)
until eof(1)
close 1
close 1

HandleEvents
</lang>

<lang futurebasic>

// Modern version
include "NSLog.incl"

local fn RunCommand( command as CFStringRef ) as CFStringRef

TaskRef tsk = fn TaskInit
TaskSetExecutableURL( tsk, fn URLFileURLWithPath( @"/bin/sh" ) )
TaskSetArguments( tsk, @[@"-c",command] )
PipeRef pip = fn PipeInit
TaskSetStandardOutput( tsk, pip )
FileHandleRef fh = fn PipeFileHandleForReading( pip )
fn TaskLaunch( tsk, NULL )
CFDataRef dta = fn FileHandleReadDataToEndOfFile( fh, NULL )
CFStringRef outputStr = fn StringWithData( dta, NSUTF8StringEncoding )
end fn = outputStr

NSLog( @"%@", fn RunCommand( @"cal 1969" ) )

HandleEvents
</lang>
</lang>


Output:
Output of either version:
<pre>
<pre>
1969
1969