Jump to content
Linuxuser1234

Keep getting Expected and identifier but received VAR same for IN and Contains

Recommended Posts

Keep getting Expected and identifier but received VAR same for IN and Contains 

 

procedure TGISEngine.AddFilenames(const AFilenames: TGISFilesnamesSHP);
begin
if (Length(AFilenames) > 0 ) then

begin
  for var in AFilenames do
  if not FFilenames.Contains(F) then
  FFilenames.Add(F);
  end;

end;

 

Share this post


Link to post

my fault:  

  • change " for var in AFilenames do" by  "for var  F  in AFilenames do"

 

xxx.AddFilenames( [  'name1', 'name2', etc... ]  );

 

 

 

Edited by programmerdelphi2k
  • Like 2

Share this post


Link to post

Well take a step back then. Do you know what you are doing? You are mixing two things here, maybe at first try this with just the important one and save the syntactic sugar of inline variables (which may still be buggy) for later:

procedure TGISEngine.AddFilenames(const AFilenames: TGISFilesnamesSHP);
var F: string; // I'm just guessing here, and maybe that is the compilers issue as well
begin
  if (Length(AFilenames) > 0 ) then
    for F in AFilenames do
      if not FFilenames.Contains(F) then
        FFilenames.Add(F);
end;

Later on, you may read what the Docwiki has to say about the limited abilities the compiler has regarding type inference and discover their examples for inlines in for...in loops all have a type declaration.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×