Solved

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

Posted on 1998-10-05
17
239 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now