Strange problem... Reset(F) has invalid syntax, where?

Hi... this is a Pascal problem but it's very strange since the sintaxis seems to be good...

Here it is:

I have:
  var
    F  : File of Byte;
  begin          
    AssignFile(F,'Hola');
    Reset(F);
    .
    .
    .
  end;

When I compile that code, I get the error message:
"Missing operator or semicolon" on the line with Reset(F);

The same error occures on line with Read(F,BufSave); and on line with CloseFile(F);

WHY?????????
thanks in advance
Jaime
   
skelAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
philipleighsConnect With a Mentor Commented:
Hi,

So it was the uses clause after all.

Why not have another look at the very first comment in this question that I added.
0
 
philipleighsCommented:
Hi,

Maybe there is a function or procedure called Reset in another unit in your uses clause.
Try replacing Reset... with System.Reset...

What does your uses clause look like?

Phil.
0
 
ZifNabCommented:
yep, code looks fine and should normally work. Zif.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
viktornetCommented:
This one must work... The syntax is prefect....

Note: Take a look at your code closer and see if you haven;t missed a semicolon somewhere in the code like....

var
  F : File of Byte;
begin
  Reset(F)   //Missing a semicolon....take a look at that..
  ...
  ...
  ...
end;

If you are sure that's now the problem please send the real code that you have so we can take a closer look at it ;-)

Regards,
Viktor Ivanov
0
 
viktornetCommented:
For example this gives the error you mentioned before.,....

var
  F : File of Byte;
begin
  AssignFile(F, 'Hola');
  Reset(F)     //No semicolon....so it gives an error....
  CloseFile(F);
end;

I guess this answer your question!

Regards,
Viktor Ivanov
0
 
skelAuthor Commented:
Here's the whole procedure... it sends that error on Reset, Read and CloseFile:

procedure TEmulador.MnuGrabarClick(Sender: TObject);
var
  Archivo   : File of byte;
  Extension : String[3];
  I         : Byte;
begin
  with DialogoAbrir do
    begin
      if Execute then
        begin
          Extension := Copy(FileName,Length(FileName)-2,3);
          for I := 1 to Length(Extension) do
            Extension[I] := UpCase(Extension[i]);
          if (Extension = 'BIN') or (Extension = '.HEX') then
            begin
              AssignFile(Archivo,FileName);
              Reset(Archivo);
              if Extension = 'BIN' then
                begin
                  Seek(Archivo,2);
                  Read(Archivo,BufSave);
                  CloseFile(Archivo);
                end;
            end
        end
    end
end;

Thanks
Jaime
0
 
viktornetCommented:
Hello!

On my computer Win95 : Delphi4 it doesn't display any other errors...this code compiles without any problems....

procedure TForm1.FormClick(Sender: TObject);
var
      Archivo   : File of byte;
   Extension : String[3];
   I         : Byte;
   BufSave        : Byte;
begin
      with DialogoAbrir do begin
            if Execute then begin
                  Extension := Copy(FileName,Length(FileName)-2,3);
                  for I := 1 to Length(Extension) do
                        Extension[I] := UpCase(Extension[i]);
                  if (Extension = 'BIN') or (Extension = '.HEX') then begin
                        AssignFile(Archivo,FileName);
                        Reset(Archivo);
                        if Extension = 'BIN' then begin
                              Seek(Archivo,2);
                              Read(Archivo,BufSave);
                              CloseFile(Archivo);
                        end;
                  end
            end
      end
end;

btw- I know it doesn't matter, but my opinion for a good programming habit is to put a semicolon after the END statement like this -> END; This way it's one easier to read and two you are sure you won't have any problems with semicolons and missing operators...

Regards,
Viktor Ivanov
0
 
skelAuthor Commented:
Thanks.... but I have the errors.. and it's impossible that I have procedures with the same names.... it's maybe a configuration problem.... may it be possible that?

I compile the code with Delphi 3 and I got the error.... I comment those procedure calls (Reset, CloseFile, Read) and the errors disappear.

I gonna get crazy trying to solve that!!!

any other suggestion?
Thanks
0
 
viktornetCommented:
Have tried using this...

Reset(F, 1); or some other syntax other than just that.....

//Vik
0
 
skelAuthor Commented:
Hi again... I've tried that...  for example, Reset(F,1)... when I compile... the cursor is placed at the beginning of F with the error Missing Operator or semicolon. I commented the previous line and the problem persist... it is exclusively of that line.

May it be a problem of Delphi options? If I can't solve the problem... I will have to use API calls directly, as a desperated solution :)

Thanks
Jaime
0
 
viktornetCommented:
Why don't you try using just a type FILE and if doesn't work then something is wrong with Delphi...

Like so..

var
  F : File;
begin
  AssignFile(F, 'Path');
  Reset(F,1);
  ...
  ...
  ...
  CloseFile(F);
end;
0
 
philipleighsCommented:
Why not just post the whole unit?

Since everyone agrees that your procedure looks ok, surely the problem lies elsewhere.
0
 
ZifNabCommented:
yep it works on my delphi 3.02 too.
0
 
viktornetCommented:
I don't know what's going on guys.... skel Please send that code of yours for the unit you use..

//Vik
0
 
kretzschmarCommented:
hi Jaime

the proposed answer above is unuseable

i cannot reproduce the error, my delphi 3.02 compiles it fine.

i think their is another reset definition in a other unit

try as follows

var f : File of byte;
begin
  assignfile(f,'XYZ');
  system.reset(f);
  closefile(f);
end;

meikl

0
 
skelAuthor Commented:
THANKS KRETZSCHMAR!!!!!!!!!!!! you have given me the right solution!! I have a control which already has a funcion Read (for that I got the problem with that function).... maybe other unit I'm using has definition for Reset.
Give me an answer now so that I will can grade you.

Regards,
Jaime

P.S. Why didn't I think about the error? hehehe :)
0
 
kretzschmarCommented:
well phil,

your first comment was right

i have overread this

best wishes

meikl
0
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.

All Courses

From novice to tech pro — start learning today.