From Clomosy Docs

No edit summary
No edit summary
Line 8: Line 8:
Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value. <br>
Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value. <br>


  '''var'''
  var
   i : Integer;<br>
   i : Integer;
  '''begin'''
   
  MyForm := TclForm.Create(Self);<br>
begin
   i := -1235;
   i := -1235;
   ShowMessage('Before: '+ IntToStr(i));
   ShowMessage('Before: '+ IntToStr(i));
   //The absolute value of i is taken and put back to i.
   //The absolute value of i is taken and put back to i.
   i:= '''Abs(i)''';
   i:= Abs(i);
   ShowMessage('After: '+IntToStr(i));<br>
   ShowMessage('After: '+IntToStr(i));
  MyForm.Run;<br>
  '''end;'''
  end;

Revision as of 15:31, 5 February 2024

function Abs(Number Numeric type):Numeric type;

Returns the absolute value of an integer.

Syntax:

value := Abs(value);

Example:
Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value.

var
 i : Integer;

begin
 i := -1235;
 ShowMessage('Before: '+ IntToStr(i));
 //The absolute value of i is taken and put back to i.
 i:= Abs(i);
 ShowMessage('After: '+IntToStr(i));

end;