Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
41
Task/File-input-output/SparForte/file-input-output.sparforte
Normal file
41
Task/File-input-output/SparForte/file-input-output.sparforte
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/local/bin/spar
|
||||
pragma annotate( summary, "filecopy" )
|
||||
@( description, "The job is to create a file called 'output.txt', and place in it" )
|
||||
@( description, "the contents of the file 'input.txt'." )
|
||||
@( category, "tutorials" )
|
||||
@( author, "Ken O. Burtch" )
|
||||
@( see_also, "http://rosettacode.org/wiki/File_IO" );
|
||||
|
||||
pragma software_model( nonstandard );
|
||||
pragma license( unrestricted );
|
||||
|
||||
procedure filecopy is
|
||||
|
||||
begin
|
||||
if not files.is_readable( "input.txt" ) then
|
||||
put_line( standard_error, source_info.source_location & ": input file is not readable" );
|
||||
command_line.set_exit_status( 192 );
|
||||
return;
|
||||
end if;
|
||||
|
||||
-- With standard shell commands
|
||||
|
||||
cp input.txt output.txt;
|
||||
|
||||
-- Using built-in capabilities
|
||||
|
||||
pragma restriction( no_external_commands );
|
||||
|
||||
declare
|
||||
inputfile : file_type;
|
||||
outputfile : file_type;
|
||||
begin
|
||||
create( outputfile, out_file, "output.txt" );
|
||||
open( inputfile, in_file, "input.txt" );
|
||||
while not end_of_file( inputfile ) loop
|
||||
put_line( outputfile, get_line( inputfile ) );
|
||||
end loop;
|
||||
close( inputfile ) @ ( outputfile );
|
||||
end;
|
||||
|
||||
end filecopy;
|
||||
Loading…
Add table
Add a link
Reference in a new issue