How to do calculations using variables?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to do calculations using variables?

roxlu
I'm looking into AsciiDoctor and wondering how to perform calculations on varaibles.

It would be great if I could define variables and then use those at other places in my document to perform calculations.

I learned that I should use macros/extensions for this, but what is unclear atm is if I should create my won extension or if there is one already that allows me to do basic math (I didn't find one).

Reply | Threaded
Open this post in threaded view
|

Re: How to do calculations using variables?

1marc1
Interesting question. Can you elaborate on your use case? What are you trying to accomplish? Can you provide an example of how you would use such functionality?

Marc.
Reply | Threaded
Open this post in threaded view
|

Re: How to do calculations using variables?

roxlu
One example would be to create an invoice e.g. a to sum up a column of a table. I'm not looking for a eleborate solution (although that would be great) to perform calculations; but even when I could just multiple, add, subtract etc. variables that would be great.
Reply | Threaded
Open this post in threaded view
|

Re: How to do calculations using variables?

David Jencks
How would you write down summing a column of unknown length using attributes and arithmetic operations? Can you get the values in the column to be set using attributes the way you expect?

David Jencks
On Mar 9, 2020, at 1:52 PM, roxlu [via Asciidoctor :: Discussion] <[hidden email]> wrote:

One example would be to create an invoice e.g. a to sum up a column of a table. I'm not looking for a eleborate solution (although that would be great) to perform calculations; but even when I could just multiple, add, subtract etc. variables that would be great.



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/How-to-do-calculations-using-variables-tp7728p7741.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to do calculations using variables?

roxlu
Yes, that would be an option.

But doing something like what is discussed here https://github.com/asciidoctor/asciidoctor/issues/1016 would be great;

I'm not sure if this feature is avaible in some way. I did not see a specific extension.