Link to home
Start Free TrialLog in
Avatar of AndrewShanklin
AndrewShanklin

asked on

Simple question: find variable in edit1.text = ?????/

Hi,

I've got a quick question:

I have on a form:

Edit1
Edit2
Button1
label1

The text in Edit1 is: User Field 1://Variable/...

User Field 1://

and

/...

remain constant throughout

However "Variable" always equals Edit2.text

So for example you could have:

Edit2.text := Andy

Edit1.text: User Field 1://Andy/...

I need to simply parse the variable in Edit1

So on button1.click --> label1.caption := the variable from edit1.text ie, Andy.


Obviously you cant just have label1.caption := Edit2.text it has to parse Edit1

If you can help please provide a full souce code snippet - it helps us all!

Many thanks

Andy.
Avatar of tobjectpascal
tobjectpascal

procedure TForm1.Button1Click(Sender: TObject);
Var
 Tmp: String;
begin
 Tmp:=Edit1.Text;
 Delete(Tmp,1,Pos('//',Edit1.Text)+1);
 Tmp:=Copy(Tmp,1,Pos('/',Tmp)-1);
 Label1.Caption:=Tmp;
end;


I think you mean that, i am half asleep right now.
ASKER CERTIFIED SOLUTION
Avatar of tobjectpascal
tobjectpascal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ferruccio Accalai
As you know the length of the Prefix part (User Field 1://) that is 15 you could simply do:

Label1.Capiton := Copy(Edit1.Text,16,pos('/...',Edit1.Text)-16);
Avatar of AndrewShanklin

ASKER

Many thanks

A.