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 consumption

Started by jj2007, May 30, 2022, 06:39:04 AM

Previous topic - Next topic

jj2007

include \masm32\MasmBasic\MasmBasic.inc                        ; download
  Init
  MovVal ST(0), Input$("\nConsumption: ", "500")               ; ask e.g. for cubic metres of water
  movaps xmm1, TimeSF(Input$("older date: ", fDate$(-30)))     ; suggest thirty days before today
  psubq TimeSF(Input$("newer date: ", fDate$())), xmm1         ; subtract from today
  FpuPush TimeDiff(d)
  Print Str$("%i days between the two dates\n", ST(0))         ; display difference in days
  fdiv
  Inkey Str$("Consumption per day: %3f units", ST(0)v)         ; calculate consumption per day
EndOfCode


The strings "500", fDate$(-30) and fDate$() are suggestions and can be edited by the user with the arrow and backspace keys. The consumption can be any number, e.g. 1.5; the dates must be entered in the correct format dd.mm.yyyy - sorry, U.S. format won't work :cool:

Example:

Consumption: 500
older date: 29.01.2022
newer date: 29.05.2022
120 days between the two dates
Consumption per day: 4.17 units


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

jj2007

Forum stats are an interesting place, but they lack some info. I wanted to know how popular our main sub-forums are, so I used the tool above as follows:
- go to the main sub-forum page, e.g. The Campus
- count the number of pages, e.g. 48 in The Campus
- click on "48" and insert the last day in the TimeDiff tool, e.g. 21.05.2012
- hit Return and confirm today's date
- enter 2400 as "consumption" (one page is 50 threads, 50*48=2400)
- see 0.584 units per day; units = threads in this case.

0.584    The Campus
0.207    The Workshop
0.113    The Laboratory

Note this is approximative; in particular, some threads have a single post, while others, like Comparing 128-bit numbers aka OWORDs in The Lab, have 321 posts.