Free Pascal Serious Problem

liunx

Guest
Hi everyone !<br />My problem comes up at reading files in pascal . I created a code that reades from a .in file some ascii characters and then prints in an .out file the letters with descending appearence and ascending alphabetical if they appeared the same number of times. While it works flawlessly with files less than 256 characters long , with larger files I cannot get the data stored in a string. <br /><br />Please help me , as this is a school project i must have ready tomorrow or at most friday and I am lost!! A couple of hours googling didn't help either...<br />Here is the code:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />$this_var = "Program Lesson9_Program1;<br /><br />Uses Crt;<br /><br />Var<br />    UserFile, Wfile : Text;<br />    TFile, tmp ,tmp1 : String;<br />    len, g, i, j, f, t : Integer;<br />    Gram :array[1..25] of String;<br />    Cram :array[1..25] of Integer;<br /><br />    {For i:=1 to 80 do<br /><br />  write(Tfile);<br />  writeln;<br /><br />  For i:=80 to 160 Do<br /><br />  write(Tfile);<br />  writeln;<br /><br />  For i:=160 to 240 Do<br /><br />  write(Tfile);<br />  writeln;<br />  For i:=240 to 257Do<br /><br />  write(Tfile);<br />  writeln;}<br /><br /><br /><br /><br />Begin<br />clrscr;<br /><br />For i:= 1 to 25 do<br />Cram:=0;<br />For g := 1 to 24 do<br /> Begin<br />Gram[g] :=char(127+g);<br />end;<br /><br />Gram[25] := ' ';<br /><br /> Assign(UserFile, 'file1.in');<br /> Reset(UserFile);<br /><br />  While not eof(Userfile) do<br />  Begin<br />  Readln(UserFile,TFile);<br />  writeln('EKANA LOOP!!!');<br />  End;<br /><br /> Close(UserFile);<br /> len:= length(TFile);<br /><br /><br /> For i:= 1 to len do<br />Begin<br />tmp := Tfile;<br />    For j := 1 to 25 do<br />     Begin<br />     If Gram[j]=tmp then<br />     Cram[j]:=Cram[j] + 1;<br /><br /><br />    end;<br />End;<br /><br /><br /><br /><br /><br /><br /><br /> for i:=2 to 25 do<br />           for j:=25 downto i do<br />               if Cram[j-1]<Cram[j] then<br />                  begin<br />                  t:=Cram[j-1];<br />                  Cram[j-1]:=Cram[j];<br />                  Cram[j]:=t;<br />                  tmp1:=gram[j-1];<br />                  gram[j-1]:=gram[j];<br />                  gram[j]:=tmp1;<br />                  end<br />                  else if Cram[j-1]=Cram[j] then<br />                       if gram[j-1]>gram[j] then<br />                          begin<br />                          t:=Cram[j-1];<br />                          Cram[j-1]:=Cram[j];<br />                          Cram[j]:=t;<br />                          tmp1:=gram[j-1];<br />                          gram[j-1]:=gram[j];<br />                          gram[j]:=tmp1;<br />                          end;<br /><br /> Assign(Wfile,'file1.out');<br /> Rewrite(Wfile);<br /><br />for i:=1 to 25 do<br />writeln(Wfile, Gram, ' ', Cram, ' ');<br /><br />close(wfile);<br />readln;<br />End.<br /><br />";<br /><!--c2--></div><!--ec2--><br /><br /><span class='edit'>This post has been edited by <b>Cobok</b>: 30 Jan, 2008 - 03:41 AM</span>
</div>
 
Top