Solved

How to split a text string

Posted on 2012-03-26
5
457 Views
Last Modified: 2012-03-27
Hello

i need split a string text

Text = <text1>,<text2>,<text3>..

can split and return text by function

getText(1) = <text1>
getText(2) = <text2>
getText(3) = <text3>
0
Comment
Question by:XSoFTz
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
Thommy earned 100 total points
ID: 37764727
Try this...

function GetText(const aDelimiter: Char;Input: string;idx:integer):string;
var
  sl: TStringlist;
begin
   sl:=TStringList.Create;
   sl.Delimiter:=aDelimiter;
   sl.DelimitedText:=Input;
   result:=sl[idx-1];
   sl.Clear;
   sl.free;
end;

Open in new window


...
GetText(',','Text1,Text2,Text3',2) = 'Text2'
0
 

Author Comment

by:XSoFTz
ID: 37771555
i problem i need return type to double ?

how to fix it ?
0
 
LVL 19

Expert Comment

by:Thommy
ID: 37771581
Can you please explain more detailled what you intend to do???
0
 

Author Comment

by:XSoFTz
ID: 37771618
can coding return to double or

can convert string to double ?
0
 
LVL 19

Expert Comment

by:Thommy
ID: 37771683
string conversion to double is only possible when string value is a floating point number representation!!!

You can convert such strings using Delphi function Val() or FloatToStr()...

Please post a new question for more help!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question