Jump to content
Sign in to follow this  
akdoto

Lisp to add numbers in a text line

Recommended Posts

akdoto

I am looking for something that can add individual numbers in multiple selected individual text objects.

 

For example one line is shown as (30) + ((2)) and another is shown as (45). The sum would be 77. The + is not in relation to actually adding the numbers it is shown on my drawings as extra material provided. 

 

Everything I have found is unable to differentiate if there are multiple individual numbers in a single text line. I have hundreds of these lines with numbers, something that would allow mass selection is also needed.

Share this post


Link to post
Share on other sites
BIGAL

A single line of text abc123fg56kl78 you can look at every character 1 at a time and what you do is check its ascii keycode.

 

Type (asccii "0") then (ascii "9") so the range is 48-57 so the test is greater than 47 and less than 58

 

Ok keywords

Strlen (strlen "abc123fg56kl78") use with repeat 

Ascii (ascii txtchr)

Substr (substr "abc123fg56kl78" x 1) where X starts at 1 keep increasing and checking is it a number

If not a number then save string of numbers 123 to a list ("123" "56" "78")

Keep checking within repeat

Do your thing with the list

Share this post


Link to post
Share on other sites
pBe

it would be interesting to see the actual line of text you're referring to akdoto

Edited by pBe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×