Solved

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

Posted on 1998-10-05
17
240 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

22 Experts available now in Live!

Get 1:1 Help Now