Fraga, Eric writes:
> On Monday, 24 Oct 2022 at 09:20, Ihor Radchenko wrote: >> I vaguely recall that storing variables in calc is something like >> variable := assignment (which is actually rewrite rule, but that's how >> 13.1 Storing Variables section of the calc manual explains variable >> assignments). > > That is true for embedded calc (which I use all the time) but I cannot > seem to get this to work for src blocks: Same: it requires using the `s s' (calc-store) command, though (which can also be done without the := assignment operator), and I've searched the manual without spotting a way to do that with algebraic entry and hence in a src block, as there doesn't seem to be any corresponding command. I hope there is a way, though! As an unsatisfying workaround, one could use :var header arguments; they work up to a point, but not with units, as Ypo wants to use (and which are are a really cool thing about Calc). Once one's using variables, it will probably be necessary to wrap the final calculation in evalv() to get a numeric value as output instead of a formula with the variable names in it. Another obstacle to what Ypo is trying to do is the attempt to use the $ sign for the currency unit. Calc does not have pre-defined currency units, and $ is taken - it refers to the last value on stack. I tend to use 'USD'. So a partial, if pointless, way to do this would be to first store the variables with the calculator: ' 300 m s s a # store a = 300 m ' 300 m s s b # store b = 300 m ' 1 USD/m^2 s s cost # store cost = (1) usd/m^2 ' a*b s s Area # store Area = a*b (*not* 90000 m^2) Then the last step could be done in a src block: #+begin_src calc evalv(Area * cost) #+end_src #+RESULTS: : 90000 USD (Another cool bit: If you change the value of a or b and rerun the src block, the result will change, since what was stored in Area was the product of the variables, not the product of their values.) Yours, Christian