News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Calculate your daily water or electricity consumption

Started by jj2007, April 23, 2023, 02:16:43 AM

Previous topic - Next topic

jj2007

This proggie calculates the difference between two dates, and optionally the consumption per day:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  movaps xmm1, TimeSF(Input$("older date: ", fDate$(-90))) ; -90: suggest ninety days before today
  psubq TimeSF(Input$("newer date: ", fDate$())), xmm1 ; subtract from today (or another date)
  Print Str$("%i days between the two dates\n", TimeDiff(d)) ; display difference in days
  .if Val(Input$("\nConsumption: ", "500")) ; ask e.g. for cubic metres of water
xchg eax, ecx ; eax is a bit too volatile
If_ not ecx==-127 Then Inkey Str$("%3f units per day\n", ecx/TimeDiff(d))  ; consumption/days
  .endif
EndOfCode


Example:
older date: 22.01.2023
newer date: 22.04.2023
90 days between the two dates

Consumption: 500
5.56 units per day


Macros used: Val, Input$(), TimeSF(), fDate$(), TimeDiff(), Str$(), Inkey

Siekmanski

Including the C02 footprint would also be nice.  :biggrin:
Creative coders use backward thinking techniques as a strategy.

daydreamer

Quote from: Siekmanski on April 23, 2023, 03:55:53 AM
Including the C02 footprint would also be nice.  :biggrin:
Pumping Coca-Cola instead calculate the % co2 in it?
Pumping water from your own well or close by river powered by petrol powered electric most accurate I think?

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding