June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,11 +1,11 @@
|
|||
file i, o;
|
||||
text s;
|
||||
|
||||
f_open(i, "input.txt", OPEN_READONLY, 0);
|
||||
f_open(o, "output.txt", OPEN_CREATE | OPEN_TRUNCATE | OPEN_WRITEONLY,
|
||||
i.open("input.txt", OPEN_READONLY, 0);
|
||||
o.open("output.txt", OPEN_CREATE | OPEN_TRUNCATE | OPEN_WRITEONLY,
|
||||
0644);
|
||||
|
||||
while (f_line(i, s) ^ -1) {
|
||||
f_text(o, s);
|
||||
f_byte(o, '\n');
|
||||
while (i.line(s) ^ -1) {
|
||||
o.text(s);
|
||||
o.byte('\n');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,40 @@
|
|||
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
|
||||
identification division.
|
||||
program-id. copyfile.
|
||||
environment division.
|
||||
input-output section.
|
||||
file-control.
|
||||
select input-file assign to "input.txt"
|
||||
organization sequential
|
||||
.
|
||||
out-file-error SECTION.
|
||||
USE AFTER ERROR ON out-file.
|
||||
DISPLAY "An error occurred while using output.txt."
|
||||
GOBACK
|
||||
select output-file assign to "output.txt"
|
||||
organization sequential
|
||||
.
|
||||
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
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,48 @@
|
|||
*> Originally from ACUCOBOL-GT
|
||||
CALL "C$COPY" USING "input.txt", "output.txt", 0
|
||||
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
|
||||
.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
*> Originally from Micro Focus COBOL
|
||||
CALL "CBL_COPY_FILE" USING "input.txt", "output.txt"
|
||||
*> Originally from ACUCOBOL-GT
|
||||
CALL "C$COPY" USING "input.txt", "output.txt", 0
|
||||
|
|
|
|||
2
Task/File-input-output/COBOL/file-input-output-4.cobol
Normal file
2
Task/File-input-output/COBOL/file-input-output-4.cobol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*> Originally from Micro Focus COBOL
|
||||
CALL "CBL_COPY_FILE" USING "input.txt", "output.txt"
|
||||
8
Task/File-input-output/Elena/file-input-output.elena
Normal file
8
Task/File-input-output/Elena/file-input-output.elena
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import system'io.
|
||||
|
||||
program =
|
||||
[
|
||||
var text := File new("input.txt"); content.
|
||||
|
||||
File new("output.txt"); saveContent(text).
|
||||
].
|
||||
10
Task/File-input-output/Forth/file-input-output-2.fth
Normal file
10
Task/File-input-output/Forth/file-input-output-2.fth
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
: INPUT$ ( text -- n n )
|
||||
pad swap accept pad swap ;
|
||||
cr ." Enter file name : " 20 INPUT$ w/o create-file throw Value fd-out
|
||||
: get-content cr ." Enter your nickname : " 20 INPUT$ fd-out write-file cr ;
|
||||
: close-output ( -- ) fd-out close-file throw ;
|
||||
get-content
|
||||
\ Inject a carriage return at end of file
|
||||
s\" \n" fd-out write-file
|
||||
close-output
|
||||
bye
|
||||
2
Task/File-input-output/Red/file-input-output.red
Normal file
2
Task/File-input-output/Red/file-input-output.red
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
file: read %input.txt
|
||||
write %output.txt file
|
||||
27
Task/File-input-output/VBA/file-input-output.vba
Normal file
27
Task/File-input-output/VBA/file-input-output.vba
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Option Explicit
|
||||
|
||||
Sub Main()
|
||||
Dim s As String, FF As Integer
|
||||
|
||||
'read a file line by line
|
||||
FF = FreeFile
|
||||
Open "C:\Users\" & Environ("username") & "\Desktop\input.txt" For Input As #FF
|
||||
While Not EOF(FF)
|
||||
Line Input #FF, s
|
||||
Debug.Print s
|
||||
Wend
|
||||
Close #FF
|
||||
|
||||
'read a file
|
||||
FF = FreeFile
|
||||
Open "C:\Users\" & Environ("username") & "\Desktop\input.txt" For Input As #FF
|
||||
s = Input(LOF(1), #FF)
|
||||
Close #FF
|
||||
Debug.Print s
|
||||
|
||||
'write a file
|
||||
FF = FreeFile
|
||||
Open "C:\Users\" & Environ("username") & "\Desktop\output.txt" For Output As #FF
|
||||
Print #FF, s
|
||||
Close #FF
|
||||
End Sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue