Author Topic: Add-Subtract Routine for Architectural/fractions  (Read 8961 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add-Subtract Routine for Architectural/fractions
« Reply #30 on: February 13, 2009, 06:34:33 PM »
Here you go Alan.  The return is in the square brackets.  I see there is some room for improvement.   :-D
Code: [Select]
(foreach i lst
    (PROMPT
        (STRCAT
            "\n"
            I
            " [ "
            (APPLY
                'STRCAT
                (addnumbersto
                    (parsestringdigit i 0)
                    1.
                )
            )
            " ]"
        )
    )
)(princ)
Code: [Select]
Could not translate: 10-1 into a number.
abc 10-1       [ abc 10-1       ]
 Could not translate: 10-1 into a number.
abc -10-1      [ abc -10-1      ]
abc 3.5        [ abc 4.5        ]
abc 3 1/2      [ abc 4 1/2      ]
abc 3 1/2"     [ abc 4 1/2"     ]
abc 3 1/2'     [ abc 3'-7"     ]
abc 3-1/2'     [ abc 3'-7"     ]
abc 3'-1"      [ abc 3'-2""      ]
abc 3'-1       [ abc 3'-2"       ]
abc 3' 1       [ abc 3'-1" 2       ]
abc 3' 1"      [ abc 3'-1" 2"      ]
abc 3' 1 1/2   [ abc 3'-2 1/2"   ]
abc 3'-1-1/2   [ abc 3'-2 1/2"   ]
abc 3' 1 1/2"  [ abc 3'-2 1/2""  ]
abc 3' 1.5     [ abc 3'-1" 2.5     ]
abc 3'.5      [ abc 3'-2"      ]
abc 3' .5      [ abc 3'-1" .6      ]
abc 3'0.5      [ abc 3'-2"      ]
abc 3'-0.5      [ abc 3'-2"      ]
abc 3' 0.5      [ abc 3'-1" 1.5      ]
abc -10        [ abc -11        ]
abc .5         [ abc .6         ]
abc 0.5        [ abc 1.5        ]
abc 5 -2       [ abc 6 -3       ]
abc 1/2        [ abc 1 1/2        ]
abc 1/2"       [ abc 1 1/2"       ]
abc 9 1/2      [ abc 10 1/2      ]
abc 1.55E+01   [ abc 2.55E+2   ]
abc 5 A        [ abc 6 A        ]
00000 [ 1 ]
abc [ abc ]
abc 3' -1"      [ abc 3'-1" -2"      ]
 Could not translate: 3'- into a number.
abc 3'- 1"      [ abc 3'- 2"      ]
abc 3' .5      [ abc 3'-1" .6      ]
 Could not translate: 10-1 into a number.
abc 10-1       [ abc 10-1       ]
 Could not translate: 10-1 into a number.
abc -10-1      [ abc -10-1      ]
abc 5A         [ abc 6A         ]
This $5.00  is 75 cents short. [ This $6.00  is 76 cents short. ]
21'  8-1/5" [ 21'-1"  9 1/4" ]
15 cde22 35 21 abc 44 [ 16 cde23 36 22 abc 45 ]
 Could not translate: 10-1-5 into a number.
abc22abc-10-1-5 def 99 [ abc23abc-10-1-5 def 100 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #31 on: February 13, 2009, 06:51:53 PM »
All in all you did a pretty go job.

My routine is to do the following.
Locate the first valid number
Increment the number found by the desired amount.
Replace the found number with the new number with the matching format & precision.
As a bonus it should maintain leading and / or trailing zeros when applicable.

As you know I'm not there yet but I may have some time tomorrow to get back to it.
Biscuits gave me the weekend off.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add-Subtract Routine for Architectural/fractions
« Reply #32 on: February 13, 2009, 07:08:03 PM »
All in all you did a pretty go job.
Thanks Alan.

My routine is to do the following.
Locate the first valid number
Increment the number found by the desired amount.
Replace the found number with the new number with the matching format & precision.
As a bonus it should maintain leading and / or trailing zeros when applicable.
This kind of what mine does.  It takes the string and makes a list out of it.  It parses the string into a list of strings and lists ( if there are numbers within the string ).  The list then states if it is a real or an integer.  If it's a real, it tries to see what format it is in, and find out what precision it is.

The next function it gets passed to adds the number supplied to all numbers within the list.  It also passes what the precision of the number supplied is, so that if it has a greater precision, then it will use that precision instead of the one the number has in the main string.  And then it passes a list of strings back.  Here it also tests to see if it is in a format that the command can use, if not is passes the same string back, and prints to the command line that one of the numbers was not a defined number that the command could use.

I must admit that you put in a little more thought than I did.  And I never would have thought about leaving the leading zeros.

As you know I'm not there yet but I may have some time tomorrow to get back to it.
Biscuits gave me the weekend off.  8-)
Good idea to take the weekend off.  Have fun.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #33 on: February 14, 2009, 11:34:48 AM »
Just got another try between tennis and Valentine Lunch.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #34 on: February 17, 2009, 09:11:53 AM »
This is so close.

The only issue I found, is that it will not add any fractional value to a whole number

Example: 52 + 1 1/2 + 53

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #35 on: February 17, 2009, 09:44:37 AM »
Arggg :-P

 :roll:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #36 on: February 17, 2009, 12:15:54 PM »
How do you feel about Capt'n Morgan and coke with a lime twist?
It's time don't ya think?
I'm buying!

mixed numbers are OK

72 + 1 1/32 = 73.03125

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #37 on: February 17, 2009, 12:38:09 PM »
Aaaah!  Cubra Libra, my favorite, how did you know. :-o
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #38 on: February 17, 2009, 12:49:54 PM »
Me thinks it was the "Arggg"!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #39 on: February 17, 2009, 12:55:34 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #40 on: February 19, 2009, 02:01:25 PM »
I want to thank you guys for sharing all your hard work!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #41 on: February 25, 2009, 07:19:35 PM »
You're welcome.

Here is another revision.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.