After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 548884 - User-defined functions do not work
User-defined functions do not work
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: docs
5.22.x
Other Linux
: Normal normal
: ---
Assigned To: gcalctool maintainers
gcalctool maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-21 17:06 UTC by Jonas Kölker
Modified: 2009-07-27 01:40 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22



Description Jonas Kölker 2008-08-21 17:06:35 UTC
1. Open the gcalctool documentation, look under "To Use Functions".
2. Try to learn how to use user-defined functions
3. Fail

Yes, this happens every time ;)

Here's the documentation of the syntax: "Click on the Value field, then enter the new value. Use the keyboard shortcuts to invoke a gcalctool button. For example, enter 90K to calculate sine(90)."

Aha, just tried that with gcalctool 5.22.3; display says "0", I click "Fun", "F0", and get "Malformed function". :(

How do I write functions?  How do I write non-constant functions?  Which kinds of functions can be written?  How would I write the identity function?  How would I write "λn.2n!"?  How would I write "λx.λy.log(y)/log(x)"?  If I can't write non-constant functions, why isn't this a part of the constants storage?

I think you should Click on the Documentation field, then enter the new value ;)
Comment 1 Rich Burridge 2008-08-22 03:27:10 UTC
Confirmed. Thanks Jonas.
Comment 2 Robert Ancell 2008-09-01 18:29:52 UTC
Rich, could you describe/link here some requirements for the function feature? I have never used them or managed to get one to work. Have they regressed due to recent changes?
Comment 3 Rich Burridge 2008-09-01 18:43:48 UTC
I'm not sure when they stopped working.

The way they used to work was that you could put a string of
keyboard equivalents in the Value field (click to edit it in the
Edit Functions dialog window). Similar thing for the Description.
The description only showed up in the Fun menu item.

So say we had

No.  Value  Description
-------------------------
0    4+4+4  Add three fours.

Then if you selected F0 from the Functions menu, "4+4+4" should be
added to whatever was currently showing in the display (at the 
cursor location).

Comment 4 Antonio Ospite 2008-09-10 20:47:41 UTC
Actually, this example does work:

No.  Value   Description
--------------------------
0    4+4+4=  Add three fours.
          ^

adding the = is the key.

And you can also use saved values:

No.  Value         Description
-------------------------------------
0    R0+(R0*20%)=  Increase R0 by 20%

I know, the smarter of us would write R0*1.2=

Inspired by this bug report http://bugzilla.gnome.org/show_bug.cgi?id=367750 I found that sin(90)= works.

Please review the documentation about that.
And maybe a glimpse at the code can be useful as well.

Another question: How to get the current value in the entry field?

Thanks,
   Antonio
Comment 5 Robert Ancell 2009-07-27 01:40:19 UTC
I've connected up the functions to the standard parser (i.e. write "sin 90" instead of "90K") and updated the documentation to reflect this.  I expect to remove the current user-defined functions in 2.30 so this solves it so they work for 2.28 but I don't think this is a great way of doing functions.