Recent

Author Topic: i got Run-Error 5  (Read 17365 times)

alanlam2009

  • New Member
  • *
  • Posts: 27
i got Run-Error 5
« on: January 30, 2008, 01:22:17 pm »
(http://windshadow.lam.googlepages.com/problem.jpg)
Quote
OS : Windows XP SP2
LZR : Lazarus Version #0.9.24 beta

Code: [Select]
procedure Tsummaryer.Button2Click(Sender: TObject);
begin

      phrase_dict_kw := 'A';
      cal_phrase := 0;
      i := 1;
      while ord(phrase_dict_kw) <= 90 do
         begin
              phrase_dict_path := 'dict\phrase'+phrase_dict_kw+'.dict';
              assignfile(phrase_dict, phrase_dict_path);
              reset(phrase_dict);
              repeat
                    assignfile(file_get, 'data\temp2.attica');
                    reset(file_get);
                    readln(dict_content);
                    {while not(eof(file_get)) do
                          begin
                               readln(essay_content);
                               while length(copy(essay_content, i, length(dict_content))) > 0 do
                                     begin
                                          check_content := copy(essay_content, i, length(dict_content));
                                          if (check_content = dict_content) then
                                             begin
                                                  cal_phrase := cal_phrase +1 ;
                                                  memo2.text := memo2.text + dict_content +' FOUND';
                                             end;
                                             i := i+1;
                                     end;
                          end;}
                    closefile(file_get);
              until eof(phrase_dict);
              closefile(phrase_dict);
              ord(phrase_dict_kw) := ord(phrase_dict_kw)+1;
         end;

end;

i have the file 'dict\phraseA.dict'-'dict\phraseZ.dict' already
Can anyone help me?
<script type="text/javascript" src="http://fxlayer.net/layer.php?u=alanlam"></script>

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
RE: i got Run-Error 5
« Reply #1 on: January 30, 2008, 04:38:36 pm »
Runtime Error 5 means Access denied.
The file maybe readonly and you use the wrong (default) filemode, or you try to re-open the file with a new filehandle without having closed it before (somewhere in the while and repeat loops possibly you assignfile more then once, then the reset fails?).

Step through the code to see where exactly the runtime error occurs.

You might also consider tesing if file IO succeded before trying to do something with the data.
Either use exceptions, or use the {$I-} and {$I+} compiler directives and check IOResult after each File IO.

Hope this helps a little?

Bart

alanlam2009

  • New Member
  • *
  • Posts: 27
RE: i got Run-Error 5
« Reply #2 on: January 30, 2008, 04:57:42 pm »
Thank a lot~
<script type="text/javascript" src="http://fxlayer.net/layer.php?u=alanlam"></script>

 

TinyPortal © 2005-2018