RobPouwelse
Technical User
Next one ..
I'll try and explain what's the problem here....
First you got the old FUNCTION
================================================
=================================================
Problem with this is that although i made an IF statement it would never work cause the index would pretty much always be > 0 (5 to be exact). So i changed it into this :
================================================
etc.
=================================================
If i'm correct, this would do the trick.. now index can be 0 before the statement.
Then i changed the function into a procedure cause of the "bad coding" post. (tnx for the info m8) so now it's this :
=================================================
==================================================
I made it a TForm cause of the Memo1 append.
Now the problem is that Index does constantly increase in value as does StrLength constantly decrease in value..
What i don't understand is, i don't have a specific line like index:=index+1; and/or Strlength:=Strlength-1;
So is the (index+5) in
permanent? why?.. do i have to do this??
=================================================
==================================================
Sorry for the long post, (and for ANOTHER one on pretty much the same subject).. oh, and i'm sorry about the bad english
I'll try and explain what's the problem here....
First you got the old FUNCTION
================================================
Code:
function Func_from (Str1, Str2 :string):string ;
var index, StrLength : integer;
begin
index := pos( Str1, Str2 ) + 5;
if index <> 0 then
begin
StrLength := pos( '>, size', Str2 ) - index;
Str1 := copy( Str2, index+1, strLength-1 );
end;
Result:=Str;
end;
Problem with this is that although i made an IF statement it would never work cause the index would pretty much always be > 0 (5 to be exact). So i changed it into this :
================================================
Code:
index := pos( Str1, Str2 );
if index <> 0 then
begin
StrLength := pos( '>, size', Str2 ) - (index+5);
=================================================
If i'm correct, this would do the trick.. now index can be 0 before the statement.
Then i changed the function into a procedure cause of the "bad coding" post. (tnx for the info m8) so now it's this :
=================================================
Code:
Procedure TForm1.Proc_from (var Str1, Str2 :string);
var index, StrLength : integer;
begin
index := pos(Str1, Str2);
if index <> 0 then
begin
StrLength := pos( '>, size', Str2 ) - (index+5);
Str1 := copy( Str2, index+1, StrLength-1 );
if Str1='' then
else Memo1.Lines.Append(Str1);
end;
end;
I made it a TForm cause of the Memo1 append.
Now the problem is that Index does constantly increase in value as does StrLength constantly decrease in value..
What i don't understand is, i don't have a specific line like index:=index+1; and/or Strlength:=Strlength-1;
So is the (index+5) in
Code:
StrLength := pos( '>, size', Str2 ) - (index+5);
=================================================
Code:
Procedure TForm1.Proc_from (var Str1, Str2 :string);
var index, StrLength : integer;
begin
index := pos(Str1, Str2);
if index <> 0 then
begin
StrLength := pos( '>, size', Str2 ) - (index+5);
Str1 := copy( Str2, index+1, StrLength-1 );
index:=index-1;
StrLength:=StrLength+1;
if Str1='' then
else Memo1.Lines.Append(Str1);
end;
end;
Sorry for the long post, (and for ANOTHER one on pretty much the same subject).. oh, and i'm sorry about the bad english