Solved

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

Posted on 1998-10-05
17
242 Views
Last Modified: 2010-04-06
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
   
0
Comment
Question by:skel
  • 6
  • 4
  • 3
  • +2
17 Comments
 
LVL 3

Expert Comment

by:philipleighs
ID: 1341823
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
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341824
yep, code looks fine and should normally work. Zif.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1341825
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 10

Expert Comment

by:viktornet
ID: 1341826
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
 

Author Comment

by:skel
ID: 1341827
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1341828
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
 

Author Comment

by:skel
ID: 1341829
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1341830
Have tried using this...

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

//Vik
0
 

Author Comment

by:skel
ID: 1341831
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1341832
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
 
LVL 3

Expert Comment

by:philipleighs
ID: 1341833
Why not just post the whole unit?

Since everyone agrees that your procedure looks ok, surely the problem lies elsewhere.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341834
yep it works on my delphi 3.02 too.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1341835
I don't know what's going on guys.... skel Please send that code of yours for the unit you use..

//Vik
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1341836
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
 

Author Comment

by:skel
ID: 1341837
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
 
LVL 3

Accepted Solution

by:
philipleighs earned 50 total points
ID: 1341838
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1341839
well phil,

your first comment was right

i have overread this

best wishes

meikl
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question