File input/output: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Omitted EasyLang) |
No edit summary |
||
Line 3,664: | Line 3,664: | ||
true |
true |
||
end handle _ => false;</syntaxhighlight> |
end handle _ => false;</syntaxhighlight> |
||
=={{header|SparForte}}== |
|||
As a structured script. |
|||
<syntaxhighlight lang="ada">#!/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;</syntaxhighlight> |
|||
=={{header|Stata}}== |
=={{header|Stata}}== |