Link to home
Start Free TrialLog in
Avatar of alshepstone
alshepstone

asked on

Parameters

I have a function which accepts two string and two integer parameters. when i trace through the program the two strings and one of the integers is working properly however the last integer seems to be reset before passing back. so for example i am passing it one large string

passstring:='Tank 1 has 27 Litres'

I am spliting the string into two one passing 'Tank' and the other 'Litres'
i am passing back the tank number '1' as an integer but when i pass the result of 27 back the function deletes it before passing back. I have followed every step with watches and have even added a line v(set as a temp integer) = 27 and tried to pass it back but as soon as the code gets to total:=v the watch not only  declaires total as empty but also the variable v (i have declaired var total :integer in the function). Can anyone help  

PS i am using Delphi 5 and Windows 98
Avatar of MBo
MBo

some code required...
ASKER CERTIFIED SOLUTION
Avatar of Cesario Lababidi
Cesario Lababidi
Flag of Germany image

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
procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
begin
  with TStringList.Create do
  try
    Text := StringReplace('Tank 1 has 27 Litres', '', #13#10, [rfReplaceAll]);
    for i := 0 to Count - 1 do
    begin
{
      Strings[i] := Trim(Strings[i]);
      you can also use this to trim before you check...

      Strings[0] is Tank
      Strings[1] is 1
      Strings[2] is has
      Strings[3] is 27
      Strings[4] is Litres
}
    end;
  finally
    Free;
  end;
end;
Is it possible that there is a call inside your function to another procedure or function that could be changing the value of the passed parameter v?

As MBo said, this would be much easier with the code of your function.

J.