Recent

Author Topic: Еличка - a simple calculator with history  (Read 5509 times)

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Еличка - a simple calculator with history
« on: March 27, 2022, 04:17:34 pm »
I could not find a simple calculator with history (like the abandoned NumLock calculator), so I have spent a few hours to make something that suits my needs.
I guess it will not hurt if I share it:
https://sourceforge.net/p/eli4ka/code/HEAD/tree/ (there is an EXE there).
The output conforms with ISO as much as possible.
The input takes numbers containing spaces as thousands separator, decimal dot is interpreted as a decimal separator.
Starting a new line with an operator applies the line to the previous result.
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12028
  • FPC developer.
Re: Еличка - a simple calculator with history
« Reply #1 on: March 27, 2022, 05:26:07 pm »
(rpnthing in FPC's git repo ? (symbolic package)

It emulates a basic stack calculator.)

Roland57

  • Sr. Member
  • ****
  • Posts: 489
    • msegui.net
Re: Еличка - a simple calculator with history
« Reply #2 on: March 27, 2022, 07:50:33 pm »
Hello!

Thank you for sharing.

Where can we find the CM630Commons package?

Regards.

Roland
My projects are on Gitlab and on Codeberg.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1156
  • Professional amateur ;-P
Re: Еличка - a simple calculator with history
« Reply #3 on: March 27, 2022, 08:13:03 pm »
Hey Roland57,

Where can we find the CM630Commons package?

Found it under the list of the user's projects: https://sourceforge.net/p/cm630commons

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

Roland57

  • Sr. Member
  • ****
  • Posts: 489
    • msegui.net
Re: Еличка - a simple calculator with history
« Reply #5 on: March 28, 2022, 07:46:58 am »
@Gustavo,CM630

Thanks for the answer. I should have seen that.  :)

Unfortunately, the project in its current state cannot be compiled under Linux.

Regards.

Roland
My projects are on Gitlab and on Codeberg.

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Еличка - a simple calculator with history
« Reply #6 on: March 28, 2022, 09:14:27 am »
A slightly modified version is committed to SVN, I hope it will compile in Linux now.
If it does not, maybe commenting the subs below will be enough:

Code: Pascal  [Select][+][-]
  1. function GetNumLock: boolean;
  2. var
  3.   KeyState : TKeyBoardState;
  4.   NLState: integer;
  5. begin
  6.    GetKeyboardState(KeyState);
  7.    NLState:=KeyState[VK_NUMLOCK];
  8.   if{ ((NLState = 0) or (NLState = 128))
  9.   or} ((NLState = 1) or (NLState = 129))
  10.   then Result := True else Result := False;
  11. end;
  12.  
  13.  
  14. procedure SetNumLock(SetOn: boolean);
  15. begin
  16.    if ((GetNumLock = true) and (SetOn = false))
  17.    or ((GetNumLock = false) and (SetOn = true)) then
  18.    begin //toggles numlock
  19.      Keybd_Event(VK_NUMLOCK, 69, KEYEVENTF_EXTENDEDKEY, 0);
  20.      Keybd_Event(VK_NUMLOCK, 69, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
  21.    end;
  22. end;  


I suppose that the EXE will work in Wine, anyway.
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

AlexTP

  • Hero Member
  • *****
  • Posts: 2526
    • UVviewsoft
Re: Еличка - a simple calculator with history
« Reply #7 on: March 28, 2022, 09:33:51 am »
Code: Pascal  [Select][+][-]
  1.   if{ ((NLState = 0) or (NLState = 128))
  2.   or} ((NLState = 1) or (NLState = 129))
  3.   then Result := True else Result := False;

Result:=   ((NLState = 1) or (NLState = 129))

Zoran

  • Hero Member
  • *****
  • Posts: 1899
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Еличка - a simple calculator with history
« Reply #8 on: March 28, 2022, 09:36:47 am »
Code: Pascal  [Select][+][-]
  1.    if ((GetNumLock = true) and (SetOn = false))
  2.    or ((GetNumLock = false) and (SetOn = true)) then
  3.  

Sorry, I cannot resist...
Yes it works, but it is so ugly. You can do better than that.
Code: Pascal  [Select][+][-]
  1. if GetNumLock xor SetOn then

You could also replace "xor" with "<>" if you prefer. But at least, please don't use "= true" and "= false".

On the other hand, you can add as many "= true" as you want, it would also work:
Code: Pascal  [Select][+][-]
  1. if ((((((GetNumLock = true) = true) = true) = true) and (((SetOn = false) = true) = true) = true)
  2.   or (((((GetNumLock = false) = true) = true) = true) and (((SetOn = true) = true) = true) = true)) = true
  3. then
  4.  
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Еличка - a simple calculator with history
« Reply #9 on: March 28, 2022, 04:15:07 pm »
You can do better than that.
Code: Pascal  [Select][+][-]
  1. if GetNumLock xor SetOn then
I do it your way when I get of fit of laziness, but these fits happen rarely.,
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Еличка - a simple calculator with history
« Reply #10 on: February 20, 2024, 10:31:32 am »
I have done some bug fixing.
There are some new features, the last one of which is autocomplete.
The app is localization-ready now.
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

gidesa

  • Full Member
  • ***
  • Posts: 160
Re: Еличка - a simple calculator with history
« Reply #11 on: February 21, 2024, 07:09:48 pm »
Hello CM630,
very nice tool!
One thing: the app saves a .txt and a .ini files with name in cyrillic characters. That names appears as "????.txt" and "?????.ini" on a not-cyrillic fonts machine, as my pc.
It could be useful  to save using the local character set of the machine.
Thank you

CM630

  • Hero Member
  • *****
  • Posts: 1247
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Еличка - a simple calculator with history
« Reply #12 on: March 15, 2024, 11:41:31 pm »
Thanks for the feedback, I will change the names of the config files.
Would you tell what your OS and locale are, I expected that filenames would be in unicode, I see Chinese filenames fine  :o


Also, the implementation of autocomplete has broken Ctrl+V somehow, I hope I will be able to fix it next week.
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
But I am sure they don't want the Trumps back...

gidesa

  • Full Member
  • ***
  • Posts: 160
Re: Еличка - a simple calculator with history
« Reply #14 on: March 16, 2024, 12:15:54 pm »
Would you tell what your OS and locale are, I expected that filenames would be in unicode, I see Chinese filenames fine  :o

Windows 10 italian version.

 

TinyPortal © 2005-2018