Create a RTF file with the MPR, and with it we realize a POWER COST CALCULATOR

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 367
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Create a RTF file with the MPR, and with it we realize a POWER COST CALCULATOR

Post by Theo_Gottwald » 09. Oct 2022, 20:53

This new topic has four important points:

1. be sure to install the latest MPR update, which you can get via ONLINE update. Otherwise the script below will not work.

2. we create here in the script a "RTF file", this is the "Richtext format" which is also used in e-mails or as Word files.

3. for this Script we use the new "INLINE-DATA-Commands". Just as shown in the script below, this way you can easily create RTF files , but also other file formats with the MPR itself.

About the electrical power:
More and more companies report that their old electricity suppliers cancel their contracts, and the new supplier wants kilowatt prices up to 1.50 EUR per kilowatt hour. Thats a lot for for energy-intensive companies.
Sometimes its more then five to ten times what companies abroad pay for electricity.

But now it like this, and anybody must assume that it is also full intention.
They said on TV that people should be forced to save energy. No matter what it costs.
Companies can now rethink, if their productions is still profitable under such circumstances or not.

Perhaps some less energy-intensive companies can manage the balancing act into the "brave new eco-world", if all employees help to save electricity.
And to "help save electricity", anybody should at least understand "what is a kilowatt hour" and "how much does electricity cost for a certain device"?

And this will start probably even with the coffee machine. Because with a price of 1,50 EUR / kw/h which runs 8 hours each day, will already cost significant money.
The Electricity-Price Calculatoir Script will tell you how much. With a 1000W Coffeemachine the price is 260 EURO per month.
For a machine with 1500 watts, it's 540 EURO per month. Here is an example of the expense (based on the 1.50 EUR /kw/h):

Code: Select all

Power:*1	Cost.*2		Cost.*3		Cost.*4

25		3,75 Cent	30 Cent		9 EUR
100 		15 cents 	1.2 EUR 	36 EUR
250 		37,5 Cent 	3 EUR 		90 EUR
500 		75 cents 	6 EUR 		180 EUR
1000 		1.5 EUR 	12 EUR 		360 EUR
2000 		3 EUR 		24 EUR 		720 EUR
11000 		16.5 EUR 	132 EUR 	3960 EUR

*1 Power in watts
*2 Cost per 1 hour
*3 Cost per day (8 hours)
*4 Cost per month (30 days) at 8 hours operation per day
To the script/program:
On the left side are the WATT NUMBERS that a device typically has. So 100 watts, or 250 WATT or 1000 watts.
For example, a typical e-car can charge with 11000 watts or more. That why 11 kw is also included.

RIGHT next to it are now the COSTS per 1 hour, 8 hours and in one full MONTH.
So you can easily see how much each device - when it runs - will cost.
And you have it in black and white. You can print it out and stick it on the wall.

If you start the MPR energy cost calculator, then the Script asks "What is the price for 1 kilowatt hour?
You have to enter that first. The price "per kilowatt hour" is given by the electricity supplier.
The "Electricity-Cost Calculator" Skript then uses this information to calculate the costs for the devices - depending on the number of watts. And writes everything into a file "Ausgabe.rtf".

Technically the script works like this:

1. in ":RTF_Geruest" we have the skeleton of such a "RTF-File" and there is the text header in the variable $$TXA. This structure is read into $$DTA.

2. in ":Ask" we ask the user for the respective price per 1 kilowatt hour. For example, the answer can be "0.40" if one kilowatt hour costs 40 cents.

3. in the main program, starting from line 30, the respective electricity costs are calculated and stored temporarily in the variable $$GES. This is done in a loop, so you can add more values - i.e. other wattages. This must then be done in line 23, there are the WATT NUMBERS that are calculated.

In ":Replacer" the placeholders built into the framework such as "*Headline*" are then replaced with the current headline. Likewise, the "*Table*" with the cost values is then inserted here.

5. the finished RTF file is written out, namely into the same folder, where also the script is. Then you can print it out and post it.

And here it is,the ELECTRICITY COST CALCULATOR MPR-Skript.
You may have laughed about it, 2 years ago. But things change fast.

Code: Select all

' +++ Strom-Rechner.rem +++
' Zweck: 
'
' Serie: 
'
' Bemerkungen: 
'
' erstellt am: 24.09.2022
' von: Theo Gottwald
'========================
'
'#EXE:?path
'#SPI:AutoSettings
'#FDC:Ask
'#MAN:ra
'
DED\1
' Ausgabe Dateiname
VAR\$$FIL=?path\Ausgabe.rtf
GSB\RTF_Geruest
' Watt-Zahlen typischer Stromverbraucher,
' 11 kw ist die typische Ladeleistung bei einem E-Auto mit 22kw Wallbox
VAR\$$WAT=25,100,250,500,1000,2000,11000
GCC\,<$$WAT>$$ANZ
VIC\$$ANZ

GSB\Ask

' Ausgabevariable löschen
VAR\$$GES=
FOR\$$WAB|1|$$ANZ
' Mit Koma getrennte Leistung aus $$ WAT entnehmen
   SBD\|$$WAT|,|$$WAB>$$WAR   
' Stromkosten pro 1 Stunde berechnen
'   CAL\$$SPS=$$ERG*$$WAR
' Stromkosten pro 1 Stunde für die angegebene Leistung
   VAR\$$FOR=$$ERG*($$WAR/1000)
   GRN\m_eval|$$FOR|>$$SPS
' GRN arbeitet mit ".", CAL\$$ mit "," als Trennzeichen
   CAL\$$SP8=$$SPS*8
   CAL\$$SP3=$$SP8*30
' EUR oder Cent?
   VAR\$$WER=$$SPS
   GSB\Check_Cur
   VAR\$$SPS=$$WER

   VAR\$$WER=$$SP8
   GSB\Check_Cur
   VAR\$$SP8=$$WER

   VAR\$$WER=$$SP3
   GSB\Check_Cur
   VAR\$$SP3=$$WER

   ' Ausgabezeile zusammenstellen
   VAR\$$OUT=$$WAR$$TAC$$SPS$$TAC$$SP8$$TAC$$SP3\par$crlf$
   VAR\$$GES=$$GES$$OUT
NXT\

VAR\$$HEA=Leist:*1\tab\tab Kost.*2\tab\tab Kost.*3\tab\tab Kost.*4\par$crlf$
VAR\$$FOO=*1 Power in watts\par$crlf$**2 Cost per 1 hour\par$crlf$*3 Cost per day (8 hours)\par$crlf$*4 Cost per month (30 days) at 8 hours operation per day\par$crlf$
' Text in RTF-Gerüst einfügen
GSB\Replacer
' Datei ausschreiben
CTF\$$FIL<$$DTA
MBX\Die Ausgabe finden Sie in der Datei*$$FIL
@
'----------------------------------------------------------------------------
'         Unterprogramme
'----------------------------------------------------------------------------
'
:Check_Cur
'RIT\|$$WER|,|.
IVV\$$WER<1
   CAL\$$WER=$$WER*100
   VAR\$$WER=$$WER Cent
ELSE
   VAR\$$WER=$$WER EUR
EVV\
RET\
'----------------------------------------------------------------------------
:Ask
' Default Stromkosten pro 1 kw/h
VAR\$$DEF=0.40
VAR\$$QUE=Geben Sie Ihren Strompreis pro 1 kw/h hier an.
VAR\$$HEA=Stromkosten-Rechner
GIP\$$QUE|$$HEA|$$DEF
VAR\$$ERG=$v1$
RET\
'----------------------------------------------------------------------------
:Replacer
GSB\RTF_Geruest
RIT\|$$DTA|*Headline*|$$HEA
RIT\|$$DTA|*Tabelle*|$$GES
RIT\|$$DTA|*Footer*|$$FOO
RET\
'----------------------------------------------------------------------------
'
'----------------------------------------------------------------------------
' Manual entered Data.
' Enthält "*Headline*" als Platzhalter für die Überschrift
' und "*Tabelle*" als Platzhalter für den Haupttext
' und "*Footer*" als Platzhalter für den Footer
'
' Rich-Text Spezifikation:
' Details: https://www.microsoft.com/en-us/download/details.aspx?id=10725
'
' \b \b0 - Bold   
' \i \i0 - Italic
' {} - Textblock
' $$DTA = Data
' $$FIN = Filename of Sourcefile
' Length:  601 Bytes in  9 Lines.
:RTF_Geruest
' Zeilenumbruch
VAR\$$UMB=\par
' Text-header mit Codepage
VAR\$$TXA=\pard\cf1\f1\fs18\lang1031$sp$
' Tabulator
VAR\$$TAC=\tab\tab$sp$
'
VAR\$$DAT=?MAACN428Ge1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZGVmZjBcbm91aWNvbXBhdFxk
VAR\$$DAT=$$DATZWZsYW5nMTAzMXtcZm9udHRibHtcZjBcZm5pbFxmY2hhcnNldDAgQ2FsaWJyaTt9
VAR\$$DAT=$$DATe1xmMVxmbmlsXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xjb2xvcnRibCA7
VAR\$$DAT=$$DATXHJlZDBcZ3JlZW4wXGJsdWUwO30NCntcKlxnZW5lcmF0b3IgUmljaGVkMjAgMTAu
VAR\$$DAT=$$DATMC4yMjAwMH1cdmlld2tpbmQ0XHVjMSANClxwYXJkXHNhMjAwXHNsMjc2XHNsbXVs
VAR\$$DAT=$$DATdDFcZjBcZnMyMlxsYW5nNyAqSGVhZGxpbmUqXHBhcg0KKlRhYmVsbGUqDQoNClxw
VAR\$$DAT=$$DATYXJkXGNmMVxmMVxmczE4XGxhbmcxMDMxICpGb290ZXIqDQpcY2YwXGYwXGZzMjJc
VAR\$$DAT=$$DATbGFuZzdccGFyDQp9Py0=
' This Line will decode the Data into the Variable $$DTA. Variable $$FIN may contain a hint about the origin of the data.
ANA\Decode|$$DAT|$$DTA|$$FIN
RET\
'----------------------------------------------------------------------------
'
'----------------------------------------------------------------------------

Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 0 guests