Author Topic: how to remove begin and end string????  (Read 1368 times)

cptang

  • Newbie
  • *
  • Posts: 9
    • View Profile
how to remove begin and end string????
« on: September 02, 2010, 08:42:48 am »
packetBegin = "start" ;
packEnd      = "end";

send code is:
nrComm1->SendString("start" + Memo1->Text + "end");
receive code is:     
Memo2->Lines->Add(Packet->Data)  ;

ex:
send   "12345"
receive "start12345end"
but i think to receive "12345"

now,my method is
    Memo2->Lines->Add(Packet->Data.SubString(Packet->PacketBegin.Length()+1,Packet->DataLength - Packet->PacketBegin.Length() - Packet->PacketEnd.Length()))  ;

thx!
« Last Edit: September 02, 2010, 08:51:43 am by cptang »

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: how to remove begin and end string????
« Reply #1 on: September 02, 2010, 11:56:57 am »
Hello

Yes you can extract useful part from data packet over SubString() method.
Please note that you can get length of header and end in following properties:
Packet->PacketBeginLength and Packet->PacketEndLength

Roman Novgorodov
DeepSoftware.com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

cptang

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: how to remove begin and end string????
« Reply #2 on: September 02, 2010, 02:24:20 pm »
Hello

Yes you can extract useful part from data packet over SubString() method.
Please note that you can get length of header and end in following properties:
Packet->PacketBeginLength and Packet->PacketEndLength

Roman Novgorodov
DeepSoftware.com

think u very much!
i use a nrDataProcessor1 component and add a datapacket
set begin and end is empty string,then it receive date is ok!