Hi all,
I'm a little sad, and maybe a little shocked...
howcome this compiles (and doesn't do what it looks to do):
purchases[i].Count -= numCovered;
and this doesn't (and why not?)
purchases[i].Count := purchases[i].Count - numCovered;
// Error: Argument cannot be assigned to
I also had tried:
purchases[i]^.Count -= numCovered;
// or even defining temp : ^TStockTransaction
temp := purchases[i];
temp^.Count -= numCovered;
But I cannot figure out how to make FPC use this access method (gvector source):
property Mutable[i : SizeUInt]: PT read getMutable;
consider purchases as TVector<TStockTransaction> and TStockTransaction is a simple record with some fields like TDateTime, String, Real, ...
type
TStockTransaction = record
StockID : String;
Basis : Real;
Count : Real;
Date : TDateTime;
end;
type
TTransactionVector = specialize TVector<TStockTransaction>;
There are many nice things about FPC/Lazarus, but some things really frustrate me, coming from C++ (of course, some things in C++ are also very frustrating coming from FPC/Lazarus, to be fair...)
>>> How can I get mutable access to records in a TVector? <<<
In fact, if you can point me to any good/best practice samples for TVector doing various tasks I'd appreciate that.
Thanks!