I am Currently in the process of doing my Assignment.
IT involves reading a Text file, and storing it into parallel
one dimensional arrays. I have to read the text file char by char, and
then add the completed string into the array. I also have to compare the
value in the array cells and determine how may times the string is
repeated, and update the corresponding numArray to reflect the
repetition occurrence. The text file is Peter Piper Picked....
I am Bottlenecked at the point where i have to read the text file char,
by char, and then form a word....I have inluced my source code (
partial).
Program Tongue_Twister;
{
Assignment 2
By Riyaz Mohamed
Comp 1450
Student A00185875
This Program, will prompt the user to indicate a text file that the
program will process. The Program will sort the Text file by
individual
words , and record their occurence. This information will then be
displayed back to the user.
{
#######################################################################}
Uses Crt;
const min=1 ;
max =50;
type WordArr = Array[min..max] of string;
NumArr = Array[min..max] of integer;
Var Word : WordArr;
Count : NumArr;
Letter : Char;
Num : integer;
FileName : String;
MyFile : text;
{
########################################################################
Procedure PauseScreen; { Pauses Screen and Prompts user
for}
{ Their
input' }
Begin
Writeln;
GoToXY(20,10);writeln(' Press Enter to Continue');
Readln;
Clrscr
End;
{ ######################################################################
Procedure InitializeArray; { Sets Values of the Array
fields to nil (no value) }
Begin
For Num := min to max Do;
Begin
Word[num] := '';
Count[num]:= 0
End
End;
{ ######################################################################
Procedure AskFile;
{ Prompts User to Enter a
Filename }
Begin
GotoXY(20,10);Writeln('Please Enter Filename ');
GoToXY(20,12);Readln( FileName );
Assign (MyFile, Filename );
Reset (Myfile)
End;
{#######################################################################
Procedure Validate(tmpwrd:string);
Var Index : Integer;
Begin
Index := 1;
While Index < ( 50 ) DO
Begin
If Tmpwrd = Word[index] then
Begin
Count[Index] := Count[Index] +1;
Index := 99
End
Else
If Word[Index] = '' Then
Begin
Word[Index] := Tmpwrd;
Count[INdex] := 1;
Index :=99
End
Else
Index := Index + 1
End
End;
{
#######################################################################}
Procedure Readfile;
Var Num : integer;
TmpWrd : String[30];
Letter : Char;
Begin
Num := 0;
While NOT EOF (MyFile) Do
Begin
Num := Num + 1;
Read (MyFile, Tmpwrd[Num]);
TmpWrd := upcase(Tmpwrd[Num]);
If TmpWrd[Num] = '' then
Validate
End
End;
Begin
Pausescreen;
InitializeArray;
AskFile;
Readfile;
Validate
End.
Appreciate the help.
Regards R. Mohamed