how do i compare array?

how do i compare an array with words?
i did a program to read a text file and store the words in an array. i need to check for the number of different words in the file. if "the" is in the file 3 times then
i will print out

Word   Appears
----   -------
"the"      3

etc .....

var
c:char;
FileName:text;
FileToOpen: string;
InWord: boolean;
Word: array[1..100] of char;
Word2: array[1..100] of char;
Count, i, occur: integer;
CharIN,CharOUT:boolean;

const
WordChar : set of char = ['A'..'Z', 'a'..'z', '-','.',',','''','"','$','!','?'];
{set of characters which is a word}
Max = 100;

procedure CheckChar;
begin
  CharIn := InWord;
  if c in WordChar then
     InWord := true
  else
  begin
     InWord := false;
  end;
  CharOut := InWord;

  if (CharIn) and not(CharOUT) then
      CheckChar := true;   ----> Error 85: ";" expected

end;

begin
Count := 0;
writeln('Enter the full pathname of the file : ');
readln(FileToOpen);
Assign(FileName, FileToOpen);
reset(FileName);

while (Count < Max) and not(eof(FileName)) do
begin
  Count := Count + 1;
  read(FileName, c);
  if CheckChar = true then
    Word[Count] := c;
end;

 Word2[1] := Word[1];

 for i:=2 to 100 do
  begin
   if Word[i] <> Word2[i-1] then
        Word2[i] := Word[i];
   else
      Occur := Occur + 1;
   end;

 writeln(Word, Occur);

 close(FileName);

 end.


daren771Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ILECommented:
100% working solution

label kraj;
var
fil: text;
s,s1:string;
i,i1:integer;
   a:array[1..1000] of string[30];
   n:array[1..1000] of integer;
begin
assign(fil,'c:\tp\prob.pas');
reset(fil); i1:=0;
while not eof(fil) do
begin
  readln(fil,s);

  while s>'' do
    begin
     i:=pos(' ',s); if i=0 then i:=length(s)+1;
     s1:=copy(s,1,i-1); s:=copy(s,i+1,255);
     for i:=1 to i1 do if a[i]=s1 then begin inc(n[i]); goto kraj; end;
       inc(i1); a[i1]:=s1; n[i1]:=1;
     kraj:
    end;

end;
close(fil);
for i:=1 to i1 do
writeln(a[i]:30,n[i]:5);
end.





0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VGRCommented:
goto and label !?!
It had been a loooong time since I saw someone daring to put this in a Pascal program 8-)
0
KocilCommented:
Ho ho ho ... poor goto & label.
My teacher would gave me E for that ;-)
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

ILECommented:
but cut some code

and to be onest with you i newer lisen too much my teacher :))
0
KocilCommented:
Well, just a story. One of my senior wrote his first program without any procedure/function. It was his undergraduate theses, so it had more than 1000 lines. The funny thing was, he used goto/label, and gave his girl friend name as the label,i.e: girl001, girl002, and so on.
The bad thing was, I was the unlucky predecessor that had to continue his work !!! After a month I've reading the girl's name over and over again, she started to jump around in my dream.

 
0
VGRCommented:
jumping in your dreams ... and in your bed ?
:D

Anyway, it's a "lovely" story, thank you 8-)

ILE : Continue to not listen too mucj to teachers, you're on the right path... Until you become a teacher yourself and start complaining about the very same behaviour :D :D
0
OkeyCommented:
Ey, maaan!
shall I do your homework?

Try this shot :
CONST
 MAX=1000;
 WORD_DIVOTION_CHAR='-';
VAR
 EXPRESSIONS_A,
 EXPRESSIONS_B:ARRAY[1..MAX]of CHAR;
 POS_IN_EXP_A,
 POS_IN_EXP_B,
 POS_OF_LAST_EXP_A,
 POS_OF_LAST_EXP_B:LONGINT;

 EXPRESSIONS:ARRAY[1..MAX]of CHAR;
 EXP_COUNTER,
 POS_IN_EXP,
 POS_OF_LAST_EXP:LONGINT;
 EXPRESSION_STR_1,
 EXPRESSION_STR_2:STRING
BEGIN
 ...
 Up to here your array has to be filled! OK.
 ...
 POS_IN_EXP_A:=1;
 POS_IN_EXP_B:=1;
 POS_OF_LAST_EXP_A:=1;
 POS_OF_LAST_EXP_B:=1;

 POS_IN_EXP:=1;
 POS_OF_LAST_EXP:=1;

 REPEAT
  EXPRESSION_STR:='';
  WHILE (EXPRESSION[POS_OF_LAST_EXP]<>WORD_DIVOTION_CHAR)
         AND
         (POS_OF_LAST_EXP<MAX)
   DO BEGIN
       EXPRESSION_STR_1:=EXPRESSION_STR_1+
                         EXPRESSION[POS_OF_LAST_EXP];
       INC(POS_OF_LAST_EXPRESSION,1);
      END;
  POS_IN_EXP:=POS_OF_LAST_EXP;

  REPEAT
   WHILE (EXPRESSION[POS_in_EXP]<>WORD_DIVOTION_CHAR)
          AND
          (POS_in_EXP<MAX)
    DO BEGIN
        EXPRESSION_STR_2:=EXPRESSION_STR_2+
                          EXPRESSION[POS_IN_EXP];
        INC(POS_IN_EXPRESSION,1);
       END;
   IF EXPRESSION_STR_1=EXPRESSION_STR_2
    then INC(EXP_COUNTER,1);
  UNTIL POS_IN_EXP=MAX;
 UNTIL POS_OF_LAST_EXP=MAX;
 
 



END.
 
0
OkeyCommented:
Ooopsy I used the Tabulator-key and space so I submitted before finnishing

Wait
does this do the JOB or what was it you tried to compare ?
The counting of redundant expression should run like this:

CONST
 MAX=1000;
 WORD_DIVOTION_CHAR='-';
VAR
 EXPRESSIONS:ARRAY[1..MAX]of CHAR;
 EXP_COUNTER,
 POS_IN_EXP,
 POS_OF_LAST_EXP:LONGINT;
 EXPRESSION_STR_1,
 EXPRESSION_STR_2:STRING
BEGIN
...
Up to here your array's have to be filled! OK.
...

The following code
will check for redundant expressions in the array

...

POS_IN_EXP:=1;
POS_OF_LAST_EXP:=1;

REPEAT
 EXPRESSION_STR:='';
 WHILE (EXPRESSION[POS_OF_LAST_EXP]<>WORD_DIVOTION_CHAR)
        AND
        (POS_OF_LAST_EXP<MAX)
  DO BEGIN
      EXPRESSION_STR_1:=EXPRESSION_STR_1+
                        EXPRESSION[POS_OF_LAST_EXP];
      INC(POS_OF_LAST_EXPRESSION,1);
     END;
 POS_IN_EXP:=POS_OF_LAST_EXP;
 EXP_COUNTER:=0;
 REPEAT
  WHILE (EXPRESSION[POS_in_EXP]<>WORD_DIVOTION_CHAR)
         AND
         (POS_in_EXP<MAX)
   DO BEGIN
       EXPRESSION_STR_2:=EXPRESSION_STR_2+
                         EXPRESSION[POS_IN_EXP];
       INC(POS_IN_EXPRESSION,1);
      END;
  IF EXPRESSION_STR_1=EXPRESSION_STR_2
   then INC(EXP_COUNTER,1);
 UNTIL POS_IN_EXP=MAX;
 WRITELN(EXPRESSION_STR_1,EXP_COUNTER:10);
UNTIL POS_OF_LAST_EXP=MAX;

END.

ARRAYs can be compared like RAM!
Following assembly snippet should return POSITION FROM WHERE THE RAM STARTS TO DIFFER
{__________________________________________________________}
Function REPE_CMPSB(Source,Dest:POINTER;Count:Word):Word;ASSEMBLER;
ASM
 PUSH  DS
 CLD
 MOV   CX,COUNT
 LDS   SI,SOURCE
 LES   DI,DEST
 REPE  CMPSB
 POP   DS
 MOV   AX,COUNT
 SUB   AX,CX
end;
{__________________________________________________________}


0
CleanupPingCommented:
daren771:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
VGRCommented:
forced answer to ILE due to lack of feedback
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.