Linuxuser1234 1 Posted December 5, 2022 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
programmerdelphi2k 237 Posted December 5, 2022 (edited) my fault: change " for var in AFilenames do" by "for var F in AFilenames do" xxx.AddFilenames( [ 'name1', 'name2', etc... ] ); Edited December 5, 2022 by programmerdelphi2k 2 Share this post Link to post
David Heffernan 2345 Posted December 6, 2022 Also the if statement is not needed and just be removed Share this post Link to post
Linuxuser1234 1 Posted December 13, 2022 On 12/5/2022 at 8:05 AM, programmerdelphi2k said: change " for var in AFilenames do" by "for var F in AFilenames do" @programmerdelphi2k that still wont work same error Share this post Link to post
programmerdelphi2k 237 Posted December 13, 2022 sorry, @Linuxuser1234 I have delete my samples, you can refresh me about this code? Share this post Link to post
Sherlock 663 Posted December 13, 2022 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