Jump to content

Calendar: Difference between revisions

Line 3,412:
=={{header|FutureBasic}}==
<lang futurebasic>
include "ConsoleWindow"
 
// Legacy version
dim as Str255 a
window 1, @"Calendar", (0, 0, 520, 520 )
 
dim as Str255 a
 
open "UNIX", 1,"cal 1969"
do
line input #1, a
print a
until eof(1)
close 1
 
HandleEvents
</lang>
 
<lang futurebasic>
 
// Modern version
include "ConsoleWindowNSLog.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>
 
Output of either version:
<pre>
1969
715

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.