Nice Easy Function Question

Hi Guys/Girls,
Straight forward one this, I have a function that passes back a string value which contains 2 seperate strings with a ^ seperator, ie

Result := 'My'+'^'+'String';

I then parser the result to obtain my two values,. Is there any way I can pass back more than one string in a function, for example

Function GetUserInf(UserCode : Integer) : String1, String2;
Begin
 Password.Locate('Key',UserCode,[]);
 String1 := Password.FieldByName('UserName').AsString;
 String2 := Password.FieldByName('PASSWORD').AsString;
End;

cheers in advance

Win95, Delphi professional 5

Stu
StuartB_99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MotazCommented:
Yes you can return two values but you can not use the result of function, instead use passing parameters by reference:

Example:

procedure GetUserInf(UserCode : Integer; var String1, String2: string);
Begin
 Password.Locate('Key',UserCode,[]);
 String1 := Password.FieldByName('UserName').AsString;
 String2 := Password.FieldByName('PASSWORD').AsString;
End;

Motaz
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kretzschmarCommented:
hi,

another way

Type TDualString = Record
                      String1 : String;
                      String2 : String;
                   end;

Function GetUserInf(UserCode : Integer) : TDualString;
Begin
 Password.Locate('Key',UserCode,[]);
 Result.String1 := Password.FieldByName('UserName').AsString;
 Result.String2 := Password.FieldByName('PASSWORD').AsString;
End

meikl
0
StuartB_99Author Commented:
Thanx Motaz, I was getting a bit sick of writing massive parser units just to format a massive result from a function, you truly have made my life a lot easier and also made my exe about 15MB smaller !!!!!! ;-)

Cheers

Stu
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.