Join two text files with a procedure, reverse a file with another procedure
Author |
Message |
SYZekrom
|
Posted: Wed Nov 18, 2015 1:03 pm Post subject: Join two text files with a procedure, reverse a file with another procedure |
|
|
What is it you are trying to achieve?
5. Write a procedure called appendFile that accepts the names of two text files. These two text files that should be joined to create the new third text file having name FirstFileNameSecondFileNameAppend.txt. Include line numbers in the output text file.
6. Write a procedure called reverseFile that accepts the name of a text file. The file should be an existing text file that will be reversed (line by line) to form the output file. Include reversed line numbers in the output text file. (Hint: you will have to open and close the input file several times). Name the output file FileNameReversed.txt.
The only instructions I got, along with structures for the code below. I frankly have no idea what I'm doing.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
It's part of a large program where you can get it to do different things to words or files
Turing: |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% v.
%
proc appendFile ( F1, F2 : string)
%generate appendfile name (Assumes that both F1 and F2 have file extensions)
const OutFN := F1 (1.. index(F1, ".") - 1) + F2 (1.. index(F2, ".") - 1) + "Append.txt"
% Open F1 and F2 to get
% Open OutFN to put
% input lines from F1 and output to OutFn until no more lines exits (including blank lines)
% input lines from F2 and output to OutFn until no more lines exits (including blank lines)
% close all files
end appendFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% w.
%
proc reverseFile ( F1 : string)
%generate appendfile name (Assumes that F1 has file extensions)
% 1 get line count N in F1 (including the blank lines)
% 2 Open OutFN to put
%3 Open F1 to get
%4 input N lines from F1
%5 output line # and line N
%6 Close input F1
%7 Update N := N -1
%8 Go to 3 (stop when N = 0)
% close all files
end reverseFile
|
I included the full file in case I'm not making sense
Please specify what version of Turing you are using
Turing 4.0
Description: |
|
Download |
Filename: |
Strtxt3.t |
Filesize: |
16.03 KB |
Downloaded: |
202 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Mon Nov 23, 2015 1:46 pm Post subject: RE:Join two text files with a procedure, reverse a file with another procedure |
|
|
it appears the logic is in the comments of the procedures, so which part are you stuck on?
|
|
|
|
|
|
|
|