Page 1 of 1

use of string.endswith

Posted: 08 Oct 2022, 08:12
by woodslanding
This method is not working for me. Maybe I misunderstand the syntax?

Here is my method:

Code: Select all

procedure findFileAndLoad;
var filenames : TStringList;
var nsfile,targetName : string; 
var i:integer;
begin
    if targetNameIN.length > 0 then
    begin
        //get commatext for file list input
        filenames.setCommatext(filelistIN.asString);
        targetName = targetNameIN.asString;
        //search for a filename that ends with the target string
        //function string.endswith   ( AValue:string ) : boolean;
        for i := 0 to filenames.count do
        begin
            nsfile = filenames.getStrings(i);
            //call load text with the found filename
            if nsfile.endswith(targetName) then loadText(nsfile);
        end;
                 
    end;
end;  
gives me 'unknown declaration 'endswith'

Thoughts?

Thanks!

Re: use of string.endswith

Posted: 08 Oct 2022, 09:41
by senso
hi, dont forget that the assignation is Pascal is:

Code: Select all

:=
not

Code: Select all

=

Code: Select all

 targetName := targetNameIN.asString;
 nsfile := filenames.getStrings(i);

Re: use of string.endswith

Posted: 15 Oct 2022, 07:12
by woodslanding
This is the problem when I go back to Pascal, after programming in anything else for a while... :/

THANKS!