Jump to content

Lisp to add numbers in a text line


akdoto

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...