Solved

How to split a text string

Posted on 2012-03-26
5
465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month5 days, 15 hours left to enroll

626 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