File input/output: Difference between revisions
→{{header|FutureBasic}}
Line 897:
</pre>
Modified May 2024
Prompts the user for an input text file.
Rich Love
<syntaxhighlight lang="futurebasic">
/*
Rosetta Code File input/output example
FutureBasic 7.0.
Rich Love
*/
Line 916 ⟶ 914:
output file "FileInputOutput.app"
void Local fn doIt
CFURLRef ParentDirectory // Create a url for the desktop
ParentDirectory = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
CFURLRef outputURL // Create a url for output.txt on the desktop
outputURL = fn URLByAppendingPathComponent( ParentDirectory, @"output.txt" )
open "O", 1, outputURL▼
CFURLRef inputURL = openpanel( 1, @"Open a text file",@"txt")
open "I", 2, inputURL▼
if inputURL = NULL then end
str255 dataLine
dataLine = ""
if fn FileManagerContentsAtURL(inputURL) <> NULL
While Not Eof(
Wend
Close #1▼
Close #2
▲Close #1
alert 3,,@"File created on Desktop",@"output.txt",@"OK"
end
else
alert 3,,@"File Not Found on Desktop",@"input.txt",@"OK"
end
end if
end fn
void local fn DoAppEvent( ev as long )
select (ev)
case _appDidFinishLaunching
fn doIt
end select
end fn
on AppEvent fn DoAppEvent
handleevents
</syntaxhighlight>
|