Lee Mac Posted April 9, 2010 Share Posted April 9, 2010 Following this thread and this thread, I thought I'd write a complementary function to allow the user to operate on numbers inside text. Example: ;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;; ;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;; ;; ;; ;; ;; ;; --=={ Text Math }==-- ;; ;; ;; ;; The program will allow the user to perform mathematical operations on Text, ;; ;; MText, Dimensions & Attributes containing numerical data. ;; ;; ;; ;; The user is prompted to select an operation (Addition, Subtraction, ;; ;; Division & Multiplication); and an operand. The user is then prompted to ;; ;; make a selection of objects to modify. ;; ;; ;; ;; If a non-commutative operation is chosen, the user will be prompted to ;; ;; specify the order of operation. ;; ;; ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;; ;; ;; ;; FUNCTION SYNTAX: TextMath / TMA ;; ;; ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;; ;; ;; ;; AUTHOR: ;; ;; ;; ;; Copyright © Lee McDonnell, April 2010. All Rights Reserved. ;; ;; ;; ;; { Contact: Lee Mac @ TheSwamp.org, CADTutor.net } ;; ;; ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;; ;; ;; ;; VERSION: ;; ;; ;; ;; ø 1.0 ~¤~ 9th April 2010 ~¤~ º First Release ;; ;;...............................................................................;; ;; ø 1.1 ~¤~ 11th April 2010 ~¤~ º Updated to include Dimensions. ;; ;; º Updated ParseNumbers function. ;; ;;...............................................................................;; ;; ;; ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;; ;; ;; ;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;; ;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;; Be careful when using with MText that contains nested formatting, comments are welcome. Lee --=={ Code Updated to Version 1.1 }==-- TextMath V1.1.lsp 1 Quote Link to comment Share on other sites More sharing options...
VovKa Posted April 11, 2010 Share Posted April 11, 2010 (ParseNumbers "-1.5") Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 Arghh! Will certainly get that fixed! Thanks mate Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 11, 2010 Share Posted April 11, 2010 (ParseNumbers "-1.5") (ParseNumbers ".3") I meant to mention it when you first posted. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 (ParseNumbers ".3") I meant to mention it when you first posted. That behaves as it should? Returns: ("." 3) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 VovKa, please try Version 1.1 Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 11, 2010 Share Posted April 11, 2010 That behaves as it should? Returns: ("." 3) I would think you would want 0.3 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 I would think you would want 0.3 But ".3" is not a valid number. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 11, 2010 Share Posted April 11, 2010 But ".3" is not a valid number. Some people may type it that way. Command: (atof ".3") 0.3 Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 11, 2010 Share Posted April 11, 2010 Do what you will with the information. I just wanted you to be aware. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 Do what you will with the information. I just wanted you to be aware. OK, thanks. Quote Link to comment Share on other sites More sharing options...
VovKa Posted April 11, 2010 Share Posted April 11, 2010 VovKa, please try Version 1.1 there is no need to try, i trust you Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2010 Author Share Posted April 11, 2010 there is no need to try, i trust you Haha... Quote Link to comment Share on other sites More sharing options...
jammie Posted September 8, 2010 Share Posted September 8, 2010 Found this routine helpful last week, had to reudce a series of levels by a constant amount. The text contained both level info & characters, worked like a charm. It was simple to use & did exactly what it said on the tin Nice work on it Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2010 Author Share Posted September 8, 2010 Thanks Jammie, I feel honoured that you could make use of it Quote Link to comment Share on other sites More sharing options...
cport Posted January 24, 2014 Share Posted January 24, 2014 This program is VERY useful, but I need the ability to specify the number of decimal points the resulting solution generates (i.e. 710.75 - 0.25 = 710.50 not 710.5). It would also be useful to only modify text that fits a particular mask (i.e. ###.##) where there are multiple numbers within an object of text (i.e. 12" E. INV. = 734.44, I don't want to perform math on the 12" text). Any chance of a update with these features? Quote Link to comment Share on other sites More sharing options...
yathishkumar Posted October 14, 2014 Share Posted October 14, 2014 good job i like it thank you very much Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 14, 2014 Author Share Posted October 14, 2014 Thank you Quote Link to comment Share on other sites More sharing options...
LibertyOne Posted October 14, 2014 Share Posted October 14, 2014 5rd, 4nd and 3st --- I like it! But closing in on this dilemma, is there a clean way of getting that to work? 1st but 11th, 2nd but 12th, 3rd but 13th Hard to just take the number from the ones column. And what happens when you subtract 2 from 2nd? 0nd About 14 years ago, I wrote a couple of little functions for adding or subtracting 1, 10, 100 or your own amount to change numeral text and attributes. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 14, 2014 Author Share Posted October 14, 2014 5rd, 4nd and 3st --- I like it!But closing in on this dilemma, is there a clean way of getting that to work? 1st but 11th, 2nd but 12th, 3rd but 13th Hard to just take the number from the ones column. And what happens when you subtract 2 from 2nd? 0nd About 14 years ago, I wrote a couple of little functions for adding or subtracting 1, 10, 100 or your own amount to change numeral text and attributes. Maybe that was a bad example for the demonstration, as this old program is really only intended to modify the numerical content in the text and does not attempt to interpret the surrounding non-numerical content. But where ordinals are concerned, perhaps the following function could be of use: (defun ordinal ( n ) (cond ((nth (rem n 10) '(nil "st" "nd" "rd"))) ("th")) ) _$ (ordinal 1) "st" _$ (ordinal 2) "nd" _$ (ordinal 3) "rd" _$ (ordinal 4) "th" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.