Код: Выделить всё
function CalcPrice(Formula: PChar; var PriceDiler, PriceIn, RateDiler,
RateIn, RateOut, Coef: double; var PriceType: integer): Double;
var
KeyLen: Word;
KeyStr: PChar;
s: AnsiString;
begin
PriceDiler := PriceDiler*RateDiler;
PriceIn := PriceIn*RateIn;
case PriceType of
-2: Result := PriceDiler*Coef;
-3: Result := PriceIn*Coef;
else
begin
KeyLen := PSmallInt(Formula)^;
KeyStr := AllocMem(KeyLen + 1);
Move((Formula + 2)^, KeyStr^, KeyLen);
s := KeyStr;
s := AnsiReplaceText(AnsiLowerCase(s), '[pricediler]', FloatToStr(PriceDiler));
s := AnsiReplaceText(s, '[pricein]', FloatToStr(PriceIn));
s := AnsiReplaceText(s, ',', '.');
Result := CalcFunction(s, 0, 0, 0);
FreeMem(KeyStr, KeyLen+1);
end;
end;
Result := RoundReal(Result/RateOut, 2);
end;
уж он то правильный или вы вобще против allocMem и Move? как тогда получить строку из PChar?
отладку я сделал в первую очередь (не настолько уж я зелен), но в том и проблема, что у меня эта отладка ничего не дает, все правильно работает