Calendar: Difference between revisions
Content added Content deleted
Line 3,412: | Line 3,412: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
<lang futurebasic> |
<lang futurebasic> |
||
⚫ | |||
// Legacy version |
|||
⚫ | |||
window 1, @"Calendar", (0, 0, 520, 520 ) |
|||
⚫ | |||
open "UNIX", 1,"cal 1969" |
open "UNIX", 1,"cal 1969" |
||
do |
|||
line input #1, a |
|||
print a |
|||
until eof(1) |
|||
close 1 |
close 1 |
||
HandleEvents |
|||
</lang> |
|||
<lang futurebasic> |
|||
// Modern version |
|||
⚫ | |||
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 |