The MASM Forum

Members Gallery => Showcase => Topic started by: jj2007 on May 30, 2022, 06:39:04 AM

Title: Calculate your daily water consumption
Post by: jj2007 on May 30, 2022, 06:39:04 AM
include \masm32\MasmBasic\MasmBasic.inc                        ; download (http://masm32.com/board/index.php?topic=94.0)
  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 (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1203), Input$ (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1041)(), TimeSF (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1328)(), fDate$() (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1267), TimeDiff (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1450)(), FpuPush (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1189), Str$ (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1186)(), Inkey (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1109)
Title: Re: Calculate your daily water consumption
Post by: jj2007 on August 10, 2023, 07:10:11 PM
Forum stats (https://masm32.com/board/index.php?action=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 (https://masm32.com/board/index.php?board=1.0)
- 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 (https://masm32.com/board/index.php?topic=2222.0) in The Lab, have 321 posts.