mathes
asked on
problem with exchanging data between 2 forms
Hi experts,
I have a problem if I want to exchange data between 2 forms.
My application consits of 2 forms:
form1:
------
drivelistbox,directorylist
commandbutton
form2:
------
3 editboxes, 1 commandbutton
If I press the button of form1, I read the selected name of the selected textfile to a string variable.
Now I open the file and want to copy the lines within the textfile to the editboxes of form2.
And this copying is not so easy for me.
I can't assign this copying to the button of form1, because in form1 the editboxes of form2 are unknown.
And if I assign this copying to the comandbutton of form2, the editboxes are known, but now the selected
filename will be an unknown identifier for Delphi.
I have one idea in my mind.
In form1 I could try something like
form2.edit1.text:'bla bla bla';
BUT; I want to manipulate the editboxes of form2 with the help of this routines:
function SplitStrAt(var s: string; position: Integer): string;
var
i, mark: Integer;
begin
mark := 0;
for i := 1 to Length(s) do begin
if (s[i] in delimiters) or (i = length(s)) then mark := i;
if (i >= position) or (i = Length(s)) then begin
Result := Copy(s, 1, mark);
Delete(s, 1, Mark);
break;
end;
end;
end;
procedure TForm1.Button1Click(Sender
var
s: string;
i: integer;
begin
s := 'This is a sample string which should be examined by the experts' +
'in order to demonstrate which result I want if I split a string.';
while s <> '' do
for i := 0 to ComponentCount - 1 do
if (Components[i] is TEdit) then
TEdit(Components[i]).Text := SplitStrAt(s, 50);
end;
But the code of
procedure TForm1.Button1Click(Sender
works only if both file selection and string manipulation are done within only one form.
As the form with the editboxes is already filled with other stuff, I have to avoid this
overloading and Imust use 2different forms.
Have you an idea, how my problem could be solved ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you for your help.
This is exactly what I was looking for.
With kind regards
Mathes