• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

cutting things out in memo1

Hi, when i paste the following code in a tmemo i want it to filter out the following into 2 edit boxes..

code Is in the code section

130510677665 into tranid.text
523726777666 into itemnum.text

Now the only things that change is them above.. everything else is the same..  so anything after 3D on the 3rd line and before _ add to the itemnum.txt


and anything from  3rdline  _ to % put in tranid.txt



thanks..

http://rover.ebay.com/rover/0/e12011.m354.l1663/7?euid=8717a842e07c4a1a9409b7aea48106bb&loc=http%3A%2F%
2Fpayments.ebay.co.uk%2Fws%2FeBayISAPI.dll%3FAddTrackingNumber%26flow%3Dmyebay%26LineID%
3D130510624444_523726338888%26ssPageName%3DADME%3AL%3AEOISSA%3AGB%3A1663

Open in new window

0
boycoder
Asked:
boycoder
  • 2
1 Solution
 
fromerCommented:

Quote from you
{
   Now the only things that change is them above.. everything else is the same..
}

If Everything else is the same, why don't just count the karakters in the full text...

196 to 207
209 to 220

 
0
 
jimyXCommented:
Here is a sample code of a code to extract those numbers:
function FindChars(str:string):boolean;
var
  i:integer;
begin
  Result := False;
  if (pos('3D',Str) > 0) and (pos('_',Str) > 0) and (pos('%',Str) > 0) then
    Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
  MemStr : string;
begin
  for i:= 0 to Memo1.Lines.Count-1 do
    begin
      MemStr := UpperCase(Memo1.Lines[i]);
      if FindChars(MemStr) then
        begin
          tranid.Text := copy(MemStr,pos('3D',MemStr)+2,pos('_',MemStr)-1-pos('3D',MemStr)-1);
          itemnum.Text := copy(MemStr,pos('_',MemStr)+1,pos('%',MemStr)-1-pos('_',MemStr));
        end;
    end;
end;

Open in new window


I have created a function to determine the memo line that has '3D' & '_' & '%'.
0
 
fromerCommented:
function GiveAnAppropriateNameToThisFunction(wholeText : String; var trainId : String; var itemNum : String) : Boolean;
var
  __Ofset : Integer;
  sigPerPos : Integer;
  sigUndPos : Integer;
begin
  __Ofset := 196;
  sigPerPos := PosEx('%', wholeText, __Ofset);
  sigUndPos := PosEx('_', wholeText, __Ofset);
  if (sigPerPos > __Ofset) and (sigUndPos > __Ofset) and (sigPerPos > sigUndPos) then
  begin
    trainId := Copy(wholeText, __Ofset, sigUndPos - __Ofset);
    itemNum := Copy(wholeText, sigUndPos + 1, sigPerPos - sigUndPos - 1);
    Result := True;
  end
  else
  begin
    Result := False;
  end;
end;
0
 
boycoderAuthor Commented:
OUTSTANDING...!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now