substring lazarus / 13-General ---------------------------------------------------------------------- Anonymous · 2006-01-12 16:01 hey guys, sorry for this stupid question, but i'm an absolute beginner. how can i get a substring?? plz write the full code... ---------------------------------------------------------------------- matthijs · 2006-01-12 16:21 Hey guy, sorry to be picky, but could you please explain what you want to do? That way we can help you better. Now we have to guess the answer you need. ---------------------------------------------------------------------- Anonymous · 2006-01-12 16:38 i want to get the button which is clicked, an then the number of this button. e.g. from 'button1.clicked' the '1'. ---------------------------------------------------------------------- matthijs · 2006-01-12 17:10 You are still not very clear, but things are getting clearer. To get the caption of the Button clicked do something like Code: [Select]   if Sender is TButton then     ShowMessage(TButton(Sender).Caption); However if you want to determine which button is clicked and perform certain actions depending on the button clicked, you are better off using the 'tag' property. Code: [Select]   if Sender is TButton then     case TButton(Sender).Tag of       1: DoSomething;       2: DoThis;       3: DoThat;     end; // case ---------------------------------------------------------------------- Anonymous · 2006-01-12 17:40 thx, this is very useful for me. but i still want to know how to get a substringof a string. i want to extract e.g. the chars 3-6 from the string 'hanspeter' and then write them into a var. in this case it would be 'nspe' ---------------------------------------------------------------------- RudieD · 2006-01-12 18:06 You can use the Copy function to return a substring. The format is   MyString := Copy(SomeString, 1 {StartPos}, 1 {Length}); or you can just cycle thru the string and just use the numbers as follows : var   Cnt : integer;   Res : string; ....   Res := '';  // Clear the result   for Cnt := 1 to Length (SomeString) do     if SomeString[Cnt] in ['0'..'9'] then       Res := Res + 'SomeString[Cnt];   // Res has all the numbers thats in the SomeString.   ... Hope this helps ! ---------------------------------------------------------------------- matthijs · 2006-01-12 18:15 For all kind of standard Pascal functions have a look at the FPC-wiki. You could also have a look at About.com. There you will find a lot of information about all kind of programming languages. Essential Pascal from Marco Cantu is also a good source of information for starters. ) But to answer your question (without making you search for it  ) see this page. The copy function is the one you are looking for. And that one is not documented. So: Code: [Select]   aSmallString := copy('hanspeter', 3, 4); would do the trick. ---------------------------------------------------------------------- Anonymous · 2006-01-12 18:33 thanks a lot