From eca925065552f6d53e9dea6914b8ec1f1dd7c931 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 19 Feb 2012 13:16:21 +0000 Subject: [PATCH] !WriteKeyValue: Fixed that formulas didn't work. --- Library/Rainmeter.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index f746d3ea..a1121ec6 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -608,23 +608,19 @@ void CRainmeter::Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow) bool formula = false; BOOL write = 0; - if (subStrings.size() > 4) + if (meterWindow) { - CMeterWindow* mw = GetMeterWindow(subStrings[4]); - if (mw) + double value; + formula = meterWindow->GetParser().ParseFormula(strValue, &value); + + // Formula read fine + if (formula) { - double value; - formula = mw->GetParser().ParseFormula(strValue, &value); + WCHAR buffer[256]; + int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", value); + CMeasure::RemoveTrailingZero(buffer, len); - // Formula read fine - if (formula) - { - WCHAR buffer[256]; - int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", value); - CMeasure::RemoveTrailingZero(buffer, len); - - write = WritePrivateProfileString(section, key, buffer, iniWrite); - } + write = WritePrivateProfileString(section, key, buffer, iniWrite); } }