List Info

Thread: Using the copy function to separate data




Using the copy function to separate data
user name
2007-01-04 21:44:49

Using your sample code, I wrote this simple test:

procedure TfrmMain.Button1Click(Sender: TObject);
var
Data : string;
begin
Data := '0.0000.1370. 000';
memo.lines.add( Copy (Data, 1, 3));
memo.lines.add( Copy (Data, 6, 8));
memo.lines.add( Copy (Data, 11, 13));
end;

Here's the result I got -

0.0
0.1370.
0. 000

That's pretty much what you're looking for, isn't it?

Joe Wilcox
"Reading Cliff Notes to know a novel is like eating Count Chocula to know steak";
"Nine women cannot have a baby in one month";
falon5000%40yahoo.com">falon5000yahoo.com


----- Original Message ----
From: Curtis cloud < curtiscld%40yahoo.com">curtiscldyahoo.com>
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Sent: Thursday, January 4, 2007 3:13:44 PM
Subject: [delphi-en] Using the copy function to separate data

ALL,

I have a telnet connection to a server computer that constant broadcast data to me each second. The data that I receive has spaces and tabs in the middle of the string. Once I receive the data I remove all spaces and tabs to get a single stream of data. After I receive the stream I attempt to parse the data into segments using the copy function.

My problem is this when I look at the stream the data looks fine but when I use the copy funtion it does not work properly on the data.

Here is an example :

Single stream from a telnet connection

0.0000.1370. 000

Data := ' 0.0000.1370. 000'

Copy (Data, 1, 3) yield value 0.0 which is fine.
Copy (Data, 6, 8) yields value 0.0000.0 which is wrong.
Copy (Data, 11, 13) yields value 0.0000.0000. 0 which is wrong.

I'm not sure why I am not receiving the correct data.

r/Curtis..

____________ _________ _________ _________ _________ __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail. yahoo.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Using the copy function to separate data
user name
2007-01-05 02:23:05

Joe,

I was looking for the following results:

0.0
0.1
0.0

r/Curtis..

joe wilcox < falon5000%40yahoo.com">falon5000yahoo.com> wrote:
Using your sample code, I wrote this simple test:

procedure TfrmMain.Button1Click(Sender: TObject);
var
Data : string;
begin
Data := '0.0000.1370. 000';
memo.lines.add( Copy (Data, 1, 3));
memo.lines.add( Copy (Data, 6, 8));
memo.lines.add( Copy (Data, 11, 13));
end;

Here's the result I got -

0.0
0.1370.
0. 000

That's pretty much what you're looking for, isn't it?

Joe Wilcox
&quot;Reading Cliff Notes to know a novel is like eating Count Chocula to know steak";
"Nine women cannot have a baby in one month";
falon5000%40yahoo.com">falon5000yahoo.com

----- Original Message ----
From: Curtis cloud < curtiscld%40yahoo.com">curtiscldyahoo.com>
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Sent: Thursday, January 4, 2007 3:13:44 PM
Subject: [delphi-en] Using the copy function to separate data

ALL,

I have a telnet connection to a server computer that constant broadcast data to me each second. The data that I receive has spaces and tabs in the middle of the string. Once I receive the data I remove all spaces and tabs to get a single stream of data. After I receive the stream I attempt to parse the data into segments using the copy function.

My problem is this when I look at the stream the data looks fine but when I use the copy funtion it does not work properly on the data.

Here is an example :

Single stream from a telnet connection

0.0000.1370. 000

Data := ' 0.0000.1370. 000'

Copy (Data, 1, 3) yield value 0.0 which is fine.
Copy (Data, 6, 8) yields value 0.0000.0 which is wrong.
Copy (Data, 11, 13) yields value 0.0000.0000. 0 which is wrong.

I'm not sure why I am not receiving the correct data.

r/Curtis..

____________ _________ _________ _________ _________ __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail. yahoo.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Using the copy function to separate data
user name
2007-01-05 03:19:17

The 3rd parameter of the Copy function is the "number" of characters to
copy from the string, not the position in the string to copy "to&quot;.

eg: Copy(Data, 6, 8) will start copying from position 6 in the string
Data, for a total of 8 characters (or EOL)
Copy(Data, 11, 13) will start copying from position 11 in the
string Data, for a total of 13 characters (or EOL)

For the results you require, you will need
Copy(Data, 1, 3);
Copy(Data, 6, 3);
Copy(Data, 11, 3);

________________________________

From: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com [mailto: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com] On
Behalf Of Curtis cloud
Sent: Friday, 5 January 2007 13:23
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Subject: Re: [delphi-en] Using the copy function to separate data

Joe,

I was looking for the following results:

0.0
0.1
0.0

r/Curtis..

joe wilcox < falon5000%40yahoo.com">falon5000yahoo.com <mailto:falon5000%40yahoo.com> > wrote:
Using your sample code, I wrote this simple test:

procedure TfrmMain.Button1Click(Sender: TObject);
var
Data : string;
begin
Data := '0.0000.1370. 000';
memo.lines.add( Copy (Data, 1, 3));
memo.lines.add( Copy (Data, 6, 8));
memo.lines.add( Copy (Data, 11, 13));
end;

Here's the result I got -

0.0
0.1370.
0. 000

That's pretty much what you're looking for, isn't it?

Joe Wilcox
&quot;Reading Cliff Notes to know a novel is like eating Count Chocula to
know steak";
"Nine women cannot have a baby in one month";
falon5000%40yahoo.com">falon5000yahoo.com <mailto:falon5000%40yahoo.com>

----- Original Message ----
From: Curtis cloud < curtiscld%40yahoo.com">curtiscldyahoo.com <mailto:curtiscld%40yahoo.com> >
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com <mailto:delphi-en%40yahoogroups.com>;
Sent: Thursday, January 4, 2007 3:13:44 PM
Subject: [delphi-en] Using the copy function to separate data

ALL,

I have a telnet connection to a server computer that constant broadcast
data to me each second. The data that I receive has spaces and tabs in
the middle of the string. Once I receive the data I remove all spaces
and tabs to get a single stream of data. After I receive the stream I
attempt to parse the data into segments using the copy function.

My problem is this when I look at the stream the data looks fine but
when I use the copy funtion it does not work properly on the data.

Here is an example :

Single stream from a telnet connection

0.0000.1370. 000

Data := ' 0.0000.1370. 000'

Copy (Data, 1, 3) yield value 0.0 which is fine.
Copy (Data, 6, 8) yields value 0.0000.0 which is wrong.
Copy (Data, 11, 13) yields value 0.0000.0000. 0 which is wrong.

I'm not sure why I am not receiving the correct data.

r/Curtis..

____________ _________ _________ _________ _________ __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail. yahoo.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com <http://mail.yahoo.com>

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Using the copy function to separate data
user name
2007-01-05 16:06:22

Thanks ,that worked, I don't know how I let that slip.

Brad Hall < brad.hall%40SecurityMail.com.au">brad.hallSecurityMail.com.au> wrote: The 3rd parameter of the Copy function is the "number" of characters to
copy from the string, not the position in the string to copy "to&quot;.

eg: Copy(Data, 6, 8) will start copying from position 6 in the string
Data, for a total of 8 characters (or EOL)
Copy(Data, 11, 13) will start copying from position 11 in the
string Data, for a total of 13 characters (or EOL)

For the results you require, you will need
Copy(Data, 1, 3);
Copy(Data, 6, 3);
Copy(Data, 11, 3);

________________________________

From: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com [mailto: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com] On
Behalf Of Curtis cloud
Sent: Friday, 5 January 2007 13:23
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Subject: Re: [delphi-en] Using the copy function to separate data

Joe,

I was looking for the following results:

0.0
0.1
0.0

r/Curtis..

joe wilcox < falon5000%40yahoo.com">falon5000yahoo.com <mailto:falon5000%40yahoo.com> > wrote:
Using your sample code, I wrote this simple test:

procedure TfrmMain.Button1Click(Sender: TObject);
var
Data : string;
begin
Data := '0.0000.1370. 000';
memo.lines.add( Copy (Data, 1, 3));
memo.lines.add( Copy (Data, 6, 8));
memo.lines.add( Copy (Data, 11, 13));
end;

Here's the result I got -

0.0
0.1370.
0. 000

That's pretty much what you're looking for, isn't it?

Joe Wilcox
&quot;Reading Cliff Notes to know a novel is like eating Count Chocula to
know steak";
"Nine women cannot have a baby in one month";
falon5000%40yahoo.com">falon5000yahoo.com <mailto:falon5000%40yahoo.com>

----- Original Message ----
From: Curtis cloud < curtiscld%40yahoo.com">curtiscldyahoo.com <mailto:curtiscld%40yahoo.com> >
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com <mailto:delphi-en%40yahoogroups.com>;
Sent: Thursday, January 4, 2007 3:13:44 PM
Subject: [delphi-en] Using the copy function to separate data

ALL,

I have a telnet connection to a server computer that constant broadcast
data to me each second. The data that I receive has spaces and tabs in
the middle of the string. Once I receive the data I remove all spaces
and tabs to get a single stream of data. After I receive the stream I
attempt to parse the data into segments using the copy function.

My problem is this when I look at the stream the data looks fine but
when I use the copy funtion it does not work properly on the data.

Here is an example :

Single stream from a telnet connection

0.0000.1370. 000

Data := ' 0.0000.1370. 000'

Copy (Data, 1, 3) yield value 0.0 which is fine.
Copy (Data, 6, 8) yields value 0.0000.0 which is wrong.
Copy (Data, 11, 13) yields value 0.0000.0000. 0 which is wrong.

I'm not sure why I am not receiving the correct data.

r/Curtis..

____________ _________ _________ _________ _________ __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail. yahoo.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com <http://mail.yahoo.com>

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )