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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...