Saving formula creates value, but doesn't save formula itself

Issue #849 invalid
Former user created an issue

If I try to save a formula, it creates a value in "variables". This is not good. Saving formula is better. I.e. I want to calculate the permanent electricity costs of my vacuum cleaner for one day, so I can save some variables like this:

#!

PowerConsumptionInKilowatts=0.5
DayInHours=24
ElectricityCostsInCentPerKilowatthour=0.2585 (living in Germany is very expensive!)

Now I wanna save a formula:

#!

ElecCostsVacCleanerPerDay=PowerConsumptionInKilowatts*DayInHours*ElectricityCostsInCentPerKilowatthour

That formula will be saved in variables and works fine. But if I change my PowerConsumptionInKilowatts after that to 0.6, there is no change in the formula.

I searched in the web for a calculator that saves formulas. But I didn't find one. I want to use this in a calc, because I need this type of function often and don't want to open a spreadsheet the whole time.

Comments (4)

  1. Tey'

    Variables are actually constants which are evaluated once and never change. For what you want, you need to define a user function instead for ElecCostsVacCleanerPerDay (note the syntax):

    #!
    
    PowerConsumptionInKilowatts=0.5
    = 0,5
    
    DayInHours=24
    = 24
    
    ElectricityCostsInCentPerKilowatthour=0.2585
    = 0,2585
    
    ElecCostsVacCleanerPerDay()=PowerConsumptionInKilowatts*DayInHours*ElectricityCostsInCentPerKilowatthour
    
    ElecCostsVacCleanerPerDay()
    = 3,102
    
    PowerConsumptionInKilowatts=0.6
    = 0,6
    
    ElecCostsVacCleanerPerDay()
    = 3,7224
    
  2. Log in to comment