Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call substring()?

I want to write a method:

Function TChunk.Chunk(Constref input: String; location: TLocation): String;
Begin
  Result := input.Substring(location.FStart, location.GetLen);
End;

but I get Error: Illegal qualified. The goal is to return a sub-string from input by a range (the location defines the range) – super simple kid’s task. I cannot:

  1. find the required string method
  2. to understand how to call string’s helper method – Substring()
  3. to understand how to do this simple task in FreePascal

My strings are unicode strings actually (i am not sure in the right terminology here, but they are not ASCII (Delphi Unicode (-MDelphiUnicode)).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help for a Pascal newbie, please 🙂

EDIT: screenshot
enter image description here

EDIT: the origin of this method
enter image description here

>Solution :

Try with copy.

instead of:

Result := input.Substring(location.FStart, location.GetLen);

use:

Result := copy(input,location.FStart,location.GetLen);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading