Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Beginners / Re: Math Question
« Last post by furious programming on Today at 04:39:50 am »
Do I have to convert everything to real to do this math?

No — of course, you can multiply the integer by float and you don't need any conversion, because the integer will be automatically converted to float before multiplication. The problem is only that the result of such a multiplication will be float, which cannot be assigned to an integer without conversion.

Therefore, either use a function that converts a floating point result to an integer (such as Round), or overwrite the operator.
2
parece-me confuso.
mas se entendi bem, você quer 30 capturas de telas (ou de janelas) capturadas de aplicações clientes e enviar para uma aplicação servidora, mostrando fragmentos ou imagens reduzidas dessas capturas?
3
General / Re: TDoubleHelper, where is the round function?
« Last post by furious programming on Today at 04:26:08 am »
An example of implementation:

Code: Pascal  [Select]
  1. {$MODESWITCH TYPEHELPERS}{$INLINE ON}
  2.  
  3. uses
  4.   SysUtils;
  5.  
  6. type
  7.   TDoubleHelper = type helper(SysUtils.TDoubleHelper) for Double
  8.   public
  9.     function Round(): Int64; inline;
  10.   end;
  11.  
  12.   function TDoubleHelper.Round(): Int64;
  13.   begin
  14.     Result := System.Round(Self);
  15.   end;

I suppose I could overload the class and add it but that works only per unit […]

Exactly, that's how the helpers work.

Quote
unless I use a INC file.

Don't do this. You still need to add one line of code in each unit, so it's better to have one helper instead of many the same (for the compiler it matters).
4
Android / Re: LAMW Send SMS improvement suggestion
« Last post by jmpessoa on Today at 03:46:09 am »

Done!!!

Thank you!!!
5
Beginners / Re: Math Question
« Last post by JLWest on Today at 03:24:38 am »
@dsiders

I did look at both of those URL's you posted and tried a few things, but kept getting an compiler error.

The ---> Answer := Round(IntValue * PercentValue); worked.

For some reason I thought everything had to be real or Integer but they couldn't be mixed within the equation.
6
General / Re: Exceptions causing Memory Leaks?
« Last post by engkin on Today at 01:33:55 am »
You need to use some defensive programming. If you create an instance of a class, use Try/Finally to make sure it gets freed when done/exception raised:
Code: Pascal  [Select]
  1.   c1 := TClass1.Create;
  2.   try
  3.     c1.func1....
  4.     ....
  5.   finally
  6.     c1.Free;
  7.   end;

Use it with every class.
7
Beginners / Re: Math Question
« Last post by dsiders on Today at 01:30:23 am »
Var
 IntValue : Integer = 119;
 PercentValue : Real = 0.04587987;
 Answer : Integer = 0;

 Can't do the following:

  Answer := IntValue * Percent;

Do I have to convert everything to real to do this math?

Would like to end up with Answer =  5.

Round
https://www.freepascal.org/docs-html/rtl/system/round.html

Int
https://www.freepascal.org/docs-html/rtl/system/int.html
8
Beginners / Re: Math Question
« Last post by lucamar on Today at 01:29:15 am »
The operation:
Code: [Select]
IntValue * Percentresults on a Real number, which can't be assigned to an Integer. Do it like this:
Code: Pascal  [Select]
  1. Answer := Round(IntValue * PercentValue);

ETA: I'm too slow :-[ Yeah, what Blaazen said.
9
Beginners / Re: Math Question
« Last post by Blaazen on Today at 01:27:55 am »
@ Do I have to convert everything to real to do this math?

Yes. Or use function to convert floating point value to integer: round() or trunc()
10
Beginners / Math Question
« Last post by JLWest on Today at 01:12:58 am »
Var
 IntValue : Integer = 119;
 PercentValue : Real = 0.04587987;
 Answer : Integer = 0;

 Can't do the following:

  Answer := IntValue * Percent;

Do I have to convert everything to real to do this math?

Would like to end up with Answer =  5. 
Pages: [1] 2 3 ... 10