Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
30
Task/File-input-output/Ada/file-input-output-1.adb
Normal file
30
Task/File-input-output/Ada/file-input-output-1.adb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Read_And_Write_File_Line_By_Line is
|
||||
Input, Output : File_Type;
|
||||
begin
|
||||
Open (File => Input,
|
||||
Mode => In_File,
|
||||
Name => "input.txt");
|
||||
Create (File => Output,
|
||||
Mode => Out_File,
|
||||
Name => "output.txt");
|
||||
loop
|
||||
declare
|
||||
Line : String := Get_Line (Input);
|
||||
begin
|
||||
-- You can process the contents of Line here.
|
||||
Put_Line (Output, Line);
|
||||
end;
|
||||
end loop;
|
||||
Close (Input);
|
||||
Close (Output);
|
||||
exception
|
||||
when End_Error =>
|
||||
if Is_Open(Input) then
|
||||
Close (Input);
|
||||
end if;
|
||||
if Is_Open(Output) then
|
||||
Close (Output);
|
||||
end if;
|
||||
end Read_And_Write_File_Line_By_Line;
|
||||
51
Task/File-input-output/Ada/file-input-output-2.adb
Normal file
51
Task/File-input-output/Ada/file-input-output-2.adb
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
with Ada.Command_Line, Ada.Text_IO; use Ada.Command_Line, Ada.Text_IO;
|
||||
|
||||
procedure Read_And_Write_File_Line_By_Line is
|
||||
Read_From : constant String := "input.txt";
|
||||
Write_To : constant String := "output.txt";
|
||||
|
||||
Input, Output : File_Type;
|
||||
begin
|
||||
begin
|
||||
Open (File => Input,
|
||||
Mode => In_File,
|
||||
Name => Read_From);
|
||||
exception
|
||||
when others =>
|
||||
Put_Line (Standard_Error,
|
||||
"Can not open the file '" & Read_From & "'. Does it exist?");
|
||||
Set_Exit_Status (Failure);
|
||||
return;
|
||||
end;
|
||||
|
||||
begin
|
||||
Create (File => Output,
|
||||
Mode => Out_File,
|
||||
Name => Write_To);
|
||||
exception
|
||||
when others =>
|
||||
Put_Line (Standard_Error,
|
||||
"Can not create a file named '" & Write_To & "'.");
|
||||
Set_Exit_Status (Failure);
|
||||
return;
|
||||
end;
|
||||
|
||||
loop
|
||||
declare
|
||||
Line : String := Get_Line (Input);
|
||||
begin
|
||||
-- You can process the contents of Line here.
|
||||
Put_Line (Output, Line);
|
||||
end;
|
||||
end loop;
|
||||
Close (Input);
|
||||
Close (Output);
|
||||
exception
|
||||
when End_Error =>
|
||||
if Is_Open(Input) then
|
||||
Close (Input);
|
||||
end if;
|
||||
if Is_Open(Output) then
|
||||
Close (Output);
|
||||
end if;
|
||||
end Read_And_Write_File_Line_By_Line;
|
||||
26
Task/File-input-output/Ada/file-input-output-3.adb
Normal file
26
Task/File-input-output/Ada/file-input-output-3.adb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
with Ada.Sequential_IO;
|
||||
|
||||
procedure Read_And_Write_File_Character_By_Character is
|
||||
package Char_IO is new Ada.Sequential_IO (Character);
|
||||
use Char_IO;
|
||||
|
||||
Input, Output : File_Type;
|
||||
Buffer : Character;
|
||||
begin
|
||||
Open (File => Input, Mode => In_File, Name => "input.txt");
|
||||
Create (File => Output, Mode => Out_File, Name => "output.txt");
|
||||
loop
|
||||
Read (File => Input, Item => Buffer);
|
||||
Write (File => Output, Item => Buffer);
|
||||
end loop;
|
||||
Close (Input);
|
||||
Close (Output);
|
||||
exception
|
||||
when End_Error =>
|
||||
if Is_Open(Input) then
|
||||
Close (Input);
|
||||
end if;
|
||||
if Is_Open(Output) then
|
||||
Close (Output);
|
||||
end if;
|
||||
end Read_And_Write_File_Character_By_Character;
|
||||
24
Task/File-input-output/Ada/file-input-output-4.adb
Normal file
24
Task/File-input-output/Ada/file-input-output-4.adb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;
|
||||
|
||||
procedure Using_Text_Streams is
|
||||
Input, Output : File_Type;
|
||||
Buffer : Character;
|
||||
begin
|
||||
Open (File => Input, Mode => In_File, Name => "input.txt");
|
||||
Create (File => Output, Mode => Out_File, Name => "output.txt");
|
||||
loop
|
||||
Buffer := Character'Input (Stream (Input));
|
||||
Character'Write (Stream (Output), Buffer);
|
||||
end loop;
|
||||
Close (Input);
|
||||
Close (Output);
|
||||
exception
|
||||
when End_Error =>
|
||||
if Is_Open(Input) then
|
||||
Close (Input);
|
||||
end if;
|
||||
if Is_Open(Output) then
|
||||
Close (Output);
|
||||
end if;
|
||||
end Using_Text_Streams;
|
||||
4
Task/File-input-output/ArkScript/file-input-output.ark
Normal file
4
Task/File-input-output/ArkScript/file-input-output.ark
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(import std.IO)
|
||||
|
||||
(let file_content (io:readFile "input.txt"))
|
||||
(io:writeFile "output.txt" file_content)
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo(!buffer:~0,-2!>output.txt
|
||||
|
|
@ -0,0 +1 @@
|
|||
<nul set/p=!buffer:~0,-2!
|
||||
40
Task/File-input-output/COBOL/file-input-output-1.cob
Normal file
40
Task/File-input-output/COBOL/file-input-output-1.cob
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
identification division.
|
||||
program-id. copyfile.
|
||||
environment division.
|
||||
input-output section.
|
||||
file-control.
|
||||
select input-file assign to "input.txt"
|
||||
organization sequential
|
||||
.
|
||||
select output-file assign to "output.txt"
|
||||
organization sequential
|
||||
.
|
||||
data division.
|
||||
file section.
|
||||
fd input-file.
|
||||
1 input-record pic x(80).
|
||||
fd output-file.
|
||||
1 output-record pic x(80).
|
||||
working-storage section.
|
||||
1 end-of-file-flag pic 9 value 0.
|
||||
88 eof value 1.
|
||||
1 text-line pic x(80).
|
||||
procedure division.
|
||||
begin.
|
||||
open input input-file
|
||||
output output-file
|
||||
perform read-input
|
||||
perform until eof
|
||||
write output-record from text-line
|
||||
perform read-input
|
||||
end-perform
|
||||
close input-file output-file
|
||||
stop run
|
||||
.
|
||||
read-input.
|
||||
read input-file into text-line
|
||||
at end
|
||||
set eof to true
|
||||
end-read
|
||||
.
|
||||
end program copyfile.
|
||||
48
Task/File-input-output/COBOL/file-input-output-2.cob
Normal file
48
Task/File-input-output/COBOL/file-input-output-2.cob
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. file-io.
|
||||
|
||||
ENVIRONMENT DIVISION.
|
||||
INPUT-OUTPUT SECTION.
|
||||
FILE-CONTROL.
|
||||
SELECT in-file ASSIGN "input.txt"
|
||||
ORGANIZATION LINE SEQUENTIAL.
|
||||
|
||||
SELECT OPTIONAL out-file ASSIGN "output.txt"
|
||||
ORGANIZATION LINE SEQUENTIAL.
|
||||
|
||||
DATA DIVISION.
|
||||
FILE SECTION.
|
||||
FD in-file.
|
||||
01 in-line PIC X(256).
|
||||
|
||||
FD out-file.
|
||||
01 out-line PIC X(256).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
DECLARATIVES.
|
||||
in-file-error SECTION.
|
||||
USE AFTER ERROR ON in-file.
|
||||
DISPLAY "An error occurred while using input.txt."
|
||||
GOBACK
|
||||
.
|
||||
out-file-error SECTION.
|
||||
USE AFTER ERROR ON out-file.
|
||||
DISPLAY "An error occurred while using output.txt."
|
||||
GOBACK
|
||||
.
|
||||
END DECLARATIVES.
|
||||
|
||||
mainline.
|
||||
OPEN INPUT in-file
|
||||
OPEN OUTPUT out-file
|
||||
|
||||
PERFORM FOREVER
|
||||
READ in-file
|
||||
AT END
|
||||
EXIT PERFORM
|
||||
END-READ
|
||||
WRITE out-line FROM in-line
|
||||
END-PERFORM
|
||||
|
||||
CLOSE in-file, out-file
|
||||
.
|
||||
2
Task/File-input-output/COBOL/file-input-output-3.cob
Normal file
2
Task/File-input-output/COBOL/file-input-output-3.cob
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*> Originally from ACUCOBOL-GT
|
||||
CALL "C$COPY" USING "input.txt", "output.txt", 0
|
||||
2
Task/File-input-output/COBOL/file-input-output-4.cob
Normal file
2
Task/File-input-output/COBOL/file-input-output-4.cob
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*> Originally from Micro Focus COBOL
|
||||
CALL "CBL_COPY_FILE" USING "input.txt", "output.txt"
|
||||
6
Task/File-input-output/Emacs-Lisp/file-input-output.el
Normal file
6
Task/File-input-output/Emacs-Lisp/file-input-output.el
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defvar input (with-temp-buffer
|
||||
(insert-file-contents "input.txt")
|
||||
(buffer-string)))
|
||||
|
||||
(with-temp-file "output.txt"
|
||||
(insert input))
|
||||
2
Task/File-input-output/Euphoria/file-input-output-1.eu
Normal file
2
Task/File-input-output/Euphoria/file-input-output-1.eu
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
include std/io.e
|
||||
write_lines("output.txt", read_lines("input.txt"))
|
||||
16
Task/File-input-output/Euphoria/file-input-output-2.eu
Normal file
16
Task/File-input-output/Euphoria/file-input-output-2.eu
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
integer in,out
|
||||
object line
|
||||
|
||||
in = open("input.txt","r")
|
||||
out = open("output.txt","w")
|
||||
|
||||
while 1 do
|
||||
line = gets(in)
|
||||
if atom(line) then -- EOF reached
|
||||
exit
|
||||
end if
|
||||
puts(out,line)
|
||||
end while
|
||||
|
||||
close(out)
|
||||
close(in)
|
||||
|
|
@ -0,0 +1 @@
|
|||
Get-Content $PWD\input.txt | Out-File $PWD\output.txt
|
||||
|
|
@ -0,0 +1 @@
|
|||
Get-Content $PWD\input.txt | Set-Content $PWD\output.txt
|
||||
7
Task/File-input-output/Rebol/file-input-output.rebol
Normal file
7
Task/File-input-output/Rebol/file-input-output.rebol
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
write %output.txt read %input.txt
|
||||
|
||||
; No line translations:
|
||||
write/binary %output.txt read/binary %input.txt
|
||||
|
||||
; Save a web page:
|
||||
write %output.html read http://example.com
|
||||
7
Task/File-input-output/Rye/file-input-output.rye
Normal file
7
Task/File-input-output/Rye/file-input-output.rye
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
str: Read %output.txt
|
||||
Write %input.txt str
|
||||
Close Open %output.txt
|
||||
Close Open %input.txt
|
||||
|
||||
cc os
|
||||
cp %output.txt %input.txt
|
||||
1
Task/File-input-output/VBScript/file-input-output.vbs
Normal file
1
Task/File-input-output/VBScript/file-input-output.vbs
Normal file
|
|
@ -0,0 +1 @@
|
|||
CreateObject("Scripting.FileSystemObject").OpenTextFile("output.txt",2,-2).Write CreateObject("Scripting.FileSystemObject").OpenTextFile("input.txt", 1, -2).ReadAll
|
||||
Loading…
Add table
Add a link
Reference in a new issue