DelphiBasics
PCurrency
Type
Pointer to a Currency value System unit
type PCurrency = ^Currency;
Description
The PCurrency type is a pointer to a Currency value.
 
Pointer arithmetic, such as Inc, Dec can be used on it, for example to navigate a block of Currency values, as in the example.
Related commands
CurrencyA decimal type with 4 decimal points used for financial values
DecDecrement an ordinal variable
IncIncrement an ordinal variable
 Download this web site as a Windows program.




 
Example code : Store 3 Currency values in memory and navigate through them
var
  currPtr : PCurrency;

begin
  // Allocate storage for three currency variables
  GetMem(currPtr, 3 * SizeOf(Currency));

  // Fill out these currency variables
  currPtr^ := 123.45;
  Inc(currPtr);
  currPtr^ := 2.9;
  Inc(currPtr);
  currPtr^ := 87654321;

  // Now display these values
  Dec(currPtr, 2);
  ShowMessageFmt('Currency 1 = %m',[currPtr^]);
  Inc(currPtr);
  ShowMessageFmt('Currency 2 = %m',[currPtr^]);
  Inc(currPtr);
  ShowMessageFmt('Currency 3 = %m',[currPtr^]);
end;
Show full unit code
  Currency 1 = ?123.45
  Currency 2 = ?2.90
  Currency 3 = ?87,654,321.00
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page