Login  Register

How to do calculations using variables?

Next Topic
 
classic Classic list List threaded Threaded
6 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

How to do calculations using variables?

roxlu
3 posts
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
| More
Print post
Permalink

Re: How to do calculations using variables?

1marc1
66 posts
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
| More
Print post
Permalink

Re: How to do calculations using variables?

roxlu
3 posts
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
| More
Print post
Permalink

Re: How to do calculations using variables?

David Jencks
68 posts
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
| More
Print post
Permalink

Re: How to do calculations using variables?

roxlu
3 posts
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.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: How to do calculations using variables?

TonK
8 posts
I am also looking for something similar to this.

Just simple calculations (+, -, *, / and something like round).

I have been looking for an extension, but I cannot seem to find it.

Does anyone know if there is an extension for this?