Bastian Müller wrote:
Hi,
I don't know if that has been discussed yet, but I've several use cases where I want to do sth. like that: A cell should be calculated by a formula if it isn't set to a value. I thought that's possible with (c-formula (:inputp t) ... ), which does calculate the slot by a formula and can be setf, but how is it possible to unset the setf value and let cells calculate it again?
Example: A textbox is by default calculated by a formula. If the user enters sth. into it, that value is used. If the user clears the field of his input, the value should be calculated again.
Could you just have?:
(or (user-entered-value self) (calculated-value self))
One thing not clear to me is how you know they first indicate they want to enter a value and then communicate that they have decided against, and those things really come into play.
Lemme know and I'll tell you how I would handle it.
Pretty much I would avoid SETF as much as possible and end up with something still formulaic:
(if (user-owns-value self) (editor-result self (key-input self)) (application-decides-value self))
Maybe the c-formula ... approach is completely the wrong way or that's not possible at all. I've read the documentation and primer but couldn't find anything helpful. Sorry, I'm new to cells.
No problem. This is a common case where one really wants to think procedurally and it gets to be a little fun thinking declaratively. But really the interesting part is this change from user-owning to application-owning mode, so lemme know your protocol for that and I will do what I can.
btw, as Jakub suggested often it is easier to divide and conquer:
(or (user-value self) (application-decided-value self))
...but I think you will end up with the same issue at some point of needing to know what state the field is in, so tell me more and I'll give it a shot.
cheers, ken
ps. might make a good use case. k