Input loop: Difference between revisions

Line 1,449:
=={{header|FutureBasic}}==
Note: This code goes beyond simply specifying the file to open. It includes a dialog window that allows the user to select a text file to read. The entire contents of the file are read in at once, rather than line by line.
<lang futurebasic>include "NSLog.incl"
include "ConsoleWindow"
 
local fn ReadTextFile
dim as CFURLRef fileRefurl
CFStringRef string
dim as Handle h
dim as CFStringRef cfStr : cfStr = NULL
url = openpanel 1, @"Select text file..."
dim as long fileLen
if ( hurl )
 
string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
if ( files$( _CFURLRefOpen, "TEXT", "Select text file...", @fileRef ) )
open "i",if 2,( fileRefstring )
fileLen = lof NSLog( 2@"%@", 1 string)
end if
h = fn NewHandleClear( fileLen )
else
if ( h )
// user cancelled
read file 2, [h], fileLen
end if
close #2
cfStr = fn CFStringCreateWithBytes( _kCFAllocatorDefault, #[h], fn GetHandleSize(h), _kCFStringEncodingMacRoman, _false )
fn DisposeH( h )
end if
else
// User canceled
end if
 
fn HIViewSetText( sConsoleHITextView, cfStr )
CFRelease( cfStr )
end fn
 
fn ReadTextFile
 
</lang>
HandleEvents</lang>
 
=={{header|gnuplot}}==
416

edits