Input loop is part of Short Circuit's Console Program Basics selection.
Task

Read from a text stream either word-by-word or line-by-line until the stream runs out of data.

The stream will have an unknown amount of data on it.




include "NSLog.incl"
 
local fn ReadTextFile
  CFURLRef    url
  CFStringRef string
 
  url = openpanel 1, @"Select text file..."
  if ( url )
    string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
    if ( string )
      NSLog(@"%@",string)
    end if
  else
    // user cancelled
  end if
end fn
 
fn ReadTextFile
 
HandleEvents