Message 1 of 49
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a Lisp that can sum two texts and bring the total to the next text?
Solved! Go to Solution.
Is there a Lisp that can sum two texts and bring the total to the next text?
Solved! Go to Solution.
Partial Slope Distance
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
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
Hello Dear
Not executed!
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
John F. Uhden
@john.uhden , thanks for your explanation .
Could this lisp be modified so as to get the same result but without + sign and prefix of 1.
Regards
Anwar shah