1 (edited by mathmathou 2015-11-12 13:15:42)

Topic: [Solved] String Manipulation

Hello Dmitry and all MVD fans,

Here is what I am trying to do :

1- Get the code of a web page with HTTPGet (Works fine)
2- Get position of a tag in that code with Pos (Works fine)
3- Delete code from 1st position to position of the tag (does not work).

The error I get is as follows :

http://i.imgur.com/CQc0fWX.jpg

What I don't understand is that StartPos given my POS(someting) is an Integer, and that DELETE(String, Integer, Integer) should recognize StartPos as an Integer.

I'm a bit lost smile

Any idea ?

procedure Form2_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    URL : String;
    Source : String;
    Longueur : String;
    StartPos : Integer;
    Source2 : String;
begin
    URL := Form2.Edit1.Text;
    Source := HTTPGet(URL);
    Longueur := IntToStr(Length(Source));
    Form2.Edit2.Text := Longueur;
    StartPos := Pos('<span class="sku_number">',Source);
    //Form2.Edit3.Text := IntToStr(StartPos);
    Source2 := Delete(Source, 1, StartPos);
    Form2.Edit4.Text := Source2;

end;

Thank you in advance and a good day to you all

Cheers

Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: [Solved] String Manipulation

Found the error !!

I was trying the create a source2 from delete on source.

But in fact source is modified by the delete function, no need to declare source2.

procedure Form2_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    URL : String;
    Source : String;
    Longueur : String;
    StartPos : Integer;
    Source2 : String;
begin
    URL := Form2.Edit1.Text;
    Source := HTTPGet(URL);
    Longueur := IntToStr(Length(Source));
    Form2.Edit2.Text := Longueur;
    StartPos := Pos('<span class="sku_number">',Source);
    Form2.Edit3.Text := IntToStr(StartPos);
    Delete(Source,1,StartPos);
    Form2.Edit4.Text := Source;

end;
I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor