GNOME Bugzilla – Bug 548884
User-defined functions do not work
Last modified: 2009-07-27 01:40:19 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 ;)
Confirmed. Thanks Jonas.
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?
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).
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
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.