Is there a Lisp that can sum two texts and bring the total to the next text?

Is there a Lisp that can sum two texts and bring the total to the next text?

Oliver_C3D
Advocate Advocate
8,360 Views
48 Replies
Message 1 of 49

Is there a Lisp that can sum two texts and bring the total to the next text?

Oliver_C3D
Advocate
Advocate

Is there a Lisp that can sum two texts and bring the total to the next text?

S01.png

0 Likes
Accepted solutions (1)
8,361 Views
48 Replies
Replies (48)
Message 41 of 49

Oliver_C3D
Advocate
Advocate

Partial Slope Distance

 

0 Likes
Message 42 of 49

dlanorh
Advisor
Advisor

Hi John, @formatsta? I think I missed that one, but I'm in the throws of the yearly hayfever saga. 🤧 

 

I wanted to move away from vl-string-subst to allow the "+" to be used in a split string function and also allow it to be used in a wcmatch in case the "+" in the string was formatted with spaces either side. It also allowed incorrectly formatted metric text strings to be processed i.e. 1 + 45.678 (should have been 1 + 045.678)

 

 

I am not one of the robots you're looking for

0 Likes
Message 43 of 49

Oliver_C3D
Advocate
Advocate

Hello @dlanorh 

You wrote that code,
Wasn't that right?

0 Likes
Message 44 of 49

john.uhden
Mentor
Mentor
Command: (setq str1 "0+024.50" str2 "1+234.50")
"1+234.50"

Command: (setq str1 (vl-string-subst "" "+" str1))
"0024.50"

Command: (setq str2 (vl-string-subst "" "+" str2))
"1234.50"

Command: (setq n1 (distof str1) n2 (distof str2) n3 (+ n1 n2))
1259.0

Command: (setq str3 (@formatsta n3 3 2))
"1+259.00"

where (it was in another thread):
   (defun @FormatSta (sta xp prec / n sign str)
     ;; where:
     ;;  sta = real or integer
     ;;  xp = exponent of 10 to specify how many numeric charcters between "+" and "."
     ;;  prec = decimal precision
     (setq n (expt 10.0 xp))
     (setq sign (if (minusp sta) "-" ""))
     (setq sta (abs sta))
     (setq str1 (strcat sign (itoa (fix (/ sta n))) "+"))
     (setq str2 (rtos (* n (rem (/ sta n) 1)) 2 prec))
     (repeat (max (- xp (strlen str2))(- xp (vl-string-position 46 str2)))
       (setq str2 (strcat "0" str2))
     )
     (strcat str1 str2)
   )

John F. Uhden

0 Likes
Message 45 of 49

Oliver_C3D
Advocate
Advocate

Hello Dear

Not executed!

0 Likes
Message 46 of 49

devitg
Advisor
Advisor

Hi @john.uhden , as you made  the @FormatSta to format number to be text with + , do you have or know about a defun to suit such text to be with the same FORMAT , as it was before I  apply your UNFORMAT. 

What I'm trying is , after   having the the new text by @formatSta , to put it with the same MTEXT format as it was before.

Hope it is clear 

0 Likes
Message 47 of 49

john.uhden
Mentor
Mentor
Sorry, but I neither have nor know of a function to reformat mtext. I
would classify it as a form of nightmare. And personally, I guess I really
don't care because internal mtext formatting is such a deterrent to typical
text modification/extraction functions. I never use internal mtext
formatting.

John F. Uhden

0 Likes
Message 48 of 49

devitg
Advisor
Advisor

@john.uhden , thanks for your explanation . 

 

0 Likes
Message 49 of 49

syedanwar70
Community Visitor
Community Visitor

Could this lisp be modified so as to get the same result but without + sign and prefix of 1.

 

Regards 

Anwar shah

0 Likes