RosettaCodeData/Task/File-input-output/FutureBasic/file-input-output.basic

56 lines
1,020 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
/*
Rosetta Code File input/output example
2024-07-13 15:19:22 -07:00
FutureBasic 7.0.24
2023-07-01 11:58:00 -04:00
Rich Love
2024-07-13 15:19:22 -07:00
5/11/24
2023-07-01 11:58:00 -04:00
*/
output file "FileInputOutput.app"
2024-07-13 15:19:22 -07:00
void Local fn doIt
2023-07-01 11:58:00 -04:00
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" )
2024-07-13 15:19:22 -07:00
CFURLRef inputURL = openpanel( 1, @"Open a text file",@"txt")
if inputURL = NULL then end
2023-07-01 11:58:00 -04:00
2024-07-13 15:19:22 -07:00
str255 dataLine
dataLine = ""
if fn FileManagerContentsAtURL(inputURL) <> NULL
open "I", 1, inputURL
open "O", 2, outputURL
While Not Eof(1)
Line Input #1, dataLine
Print #2, dataLine
2023-07-01 11:58:00 -04:00
Wend
Close #2
2024-07-13 15:19:22 -07:00
Close #1
alert 3,,@"File created on Desktop",@"output.txt",@"OK"
end
else
alert 3,,@"File Not Found on Desktop",@"input.txt",@"OK"
2023-07-01 11:58:00 -04:00
end
2024-07-13 15:19:22 -07:00
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