File input/output: Difference between revisions

Content added Content deleted
(Added Odin variant)
No edit summary
Line 1,937: Line 1,937:
w.print[contents]
w.print[contents]
w.close[]
w.close[]
</syntaxhighlight>

=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">

/*

Rosetta Code File input/output example
FutureBasic 7.0.14

Rich Love
9/25/22

Before running this, use TextEdit to create a file called input.txt on your desktop.
Format as plain text and create a few lines of text.
Then save.

*/

output file "FileInputOutput.app"

CFURLRef ParentDirectory // Create a url for the desktop
ParentDirectory = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )

CFURLRef inputURL // Create a url for input.txt on the desktop
inputURL = fn URLByAppendingPathComponent( ParentDirectory, @"input.txt" )

CFURLRef outputURL // Create a url for output.txt on the desktop
outputURL = fn URLByAppendingPathComponent( ParentDirectory, @"output.txt" )

open "O", 1, outputURL
open "I", 2, inputURL

str255 dataLine

While Not Eof(2)
Line Input #2, dataLine
Print #1, dataLine
Wend

Close #1
Close #2

end

</syntaxhighlight>
</syntaxhighlight>