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
Currency A decimal type with 4 decimal points used for financial values
Dec Decrement an ordinal variable
Inc Increment an ordinal variable
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Store 3 Currency values in memory and navigate through them
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

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;
 
end.
Hide full unit code
   Currency 1 = ?123.45
   Currency 2 = ?2.90
   Currency 3 = ?87,654,321.00
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page