Form Letters and Arithmetic Operations - Addition
-
Anonymous User
Form Letters and Arithmetic Operations - Addition
A user sent me an Email requesting information on how to do addition and multiplication in form letters. This example allows one to input 4 numbers. A1-Law then adds them together and prints the result and then multiplies that result by 5 and prints the result of that. Here is an example:
>
>
>
Fee 1: >
Fee 2: >
Fee 3: >
Fee 4: >
Total: >
Total * 5: >
>
>
>
Fee 1: >
Fee 2: >
Fee 3: >
Fee 4: >
Total: >
Total * 5: >
Re: Form Letters and Arithmetic Operations - Addition
Here's an example of code we use in a depo fee letter:
>>>
Travel Time: > minutes
Client briefing: > minutes
Deposition: > minutes
TOTAL: > minutes
Pursuant to Labor Code Section 5710 reasonable attorneys fee are requested in the amount of $> to be forwarded to this office within 30 days of this letter.
-We input the minutes for each part when the template is used (memory 43 - 45). It then adds up those minutes (memory 51) and multiplies it by our depo fee amount per hour and divides by 60 min/hour (to get the grand total $ - memory 60).
-The only drawback with this setup is that everything has to be broken down into minutes at the initial input. 2 hours = 120 minutes, etc. If anyone attempts to input hours + minutes (2 hours, 20 minutes) it messes up the calculations.
-Hope this helps! Btw, Is there any way this code can be "cleaned-up" Michael?
Thanks!
Sincerely, Michael Lerner - Lerner, Moore, Silva, Cunningham & Rubel
>>>
Travel Time: > minutes
Client briefing: > minutes
Deposition: > minutes
TOTAL: > minutes
Pursuant to Labor Code Section 5710 reasonable attorneys fee are requested in the amount of $> to be forwarded to this office within 30 days of this letter.
-We input the minutes for each part when the template is used (memory 43 - 45). It then adds up those minutes (memory 51) and multiplies it by our depo fee amount per hour and divides by 60 min/hour (to get the grand total $ - memory 60).
-The only drawback with this setup is that everything has to be broken down into minutes at the initial input. 2 hours = 120 minutes, etc. If anyone attempts to input hours + minutes (2 hours, 20 minutes) it messes up the calculations.
-Hope this helps! Btw, Is there any way this code can be "cleaned-up" Michael?
Thanks!
Sincerely, Michael Lerner - Lerner, Moore, Silva, Cunningham & Rubel
Sincerely,
Michael Lerner
Network Administrator
Lerner, Moore, Silva, Cunningham & Rubel
www.injuryatwork.com
(909) 889-1131
Michael Lerner
Network Administrator
Lerner, Moore, Silva, Cunningham & Rubel
www.injuryatwork.com
(909) 889-1131
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
Overall the coding looks fine. If there was really a lot of math then it is possible to create a separate "function library" to manage it which might be cleaner but given that it is just a few lines it's probably best to keep it as is for now. Regarding minutes and hours I know some firms use decimals (tenths/hour) instead so they might input 2.3 (which is 2 hours plus 3 * 6 minutes = 2 hours, 18 minutes).
Mike
Mike
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
Mike,
Is it possible to perform two different arithmetic operations in one line? In our case (which is also for a deposition bill), we'd like to multiply the total number of hours by the hourly rate, and simultaneously add to that product any parking fees we had to pay. Here's the code as it exists right now:
>
Preparation: >
Deposition: >
Travel Time: >
TOTAL TIME: >>
Parking: $>
TOTAL AMOUNT DUE: $>>>
As you can see, this is a work in progress, since the total amount due calculates only total time * hourly rate. I tried writing this:
>
but a message popped up saying that code doesn't work. We realize that there could be an extra line in the bill that dispalys the amount due for time spent (and save that total in a memory variable), then display the parking amount, then display the totoal amount due (by adding the last two memory variables). However, we'd like to see if it'd be possible to make the bill more concise by not including that extra line.
Thanks for the help.
Is it possible to perform two different arithmetic operations in one line? In our case (which is also for a deposition bill), we'd like to multiply the total number of hours by the hourly rate, and simultaneously add to that product any parking fees we had to pay. Here's the code as it exists right now:
>
Preparation: >
Deposition: >
Travel Time: >
TOTAL TIME: >>
Parking: $>
TOTAL AMOUNT DUE: $>>>
As you can see, this is a work in progress, since the total amount due calculates only total time * hourly rate. I tried writing this:
>
but a message popped up saying that code doesn't work. We realize that there could be an extra line in the bill that dispalys the amount due for time spent (and save that total in a memory variable), then display the parking amount, then display the totoal amount due (by adding the last two memory variables). However, we'd like to see if it'd be possible to make the bill more concise by not including that extra line.
Thanks for the help.
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
Your effort above was excellent and very close. Try copying and pasting this code instead (although very similar):
>
Preparation: >
Deposition: >
Travel Time: >
>
TOTAL TIME: >
Parking: $>
>
TOTAL AMOUNT DUE: $>>
RATE (remove if you don't need this printed) >
Parking (remove if you don't need this printed) >
>
Preparation: >
Deposition: >
Travel Time: >
>
TOTAL TIME: >
Parking: $>
>
TOTAL AMOUNT DUE: $>>
RATE (remove if you don't need this printed) >
Parking (remove if you don't need this printed) >
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
Hey Mike,
I've got a new question on this topic. I copied your code for adding two numbers from the help file, then changed the "+" to a "-". However, I've run into several issues.
1. When I use that code to subtract two numbers that a user has entered, it doesn't work properly if the user has used a comma. For example, if the user enters 25,000 for the first number and 5,000 for the second, the operation spits out 20 instead of 20,000. - i.e. it ignores all numbers after the comma. This problem doesn't arise if commas aren't used when inputting the initial two numbers. However, since the numbers entered represent dollar figures, it would be nice to be able to use a comma.
2. I understand that the final two numbers in the addition command represent how many spaces are alloted for the answer and how many decimal places will be used. However, if we allot, say, 9 spaces for the answer but end up only using 5, there's a gap of four spaces between whatever comes before the code and the result of the code. For example, our answer might read something like this: $ 350.00. Is there a way to have the code use only as many spaces as necessary?
Neither of these are major issues, since the user can always edit the final letter to insert commas and delete extra spaces. However, having those operations completed automatically would be great.
Thanks,
Patrick
I've got a new question on this topic. I copied your code for adding two numbers from the help file, then changed the "+" to a "-". However, I've run into several issues.
1. When I use that code to subtract two numbers that a user has entered, it doesn't work properly if the user has used a comma. For example, if the user enters 25,000 for the first number and 5,000 for the second, the operation spits out 20 instead of 20,000. - i.e. it ignores all numbers after the comma. This problem doesn't arise if commas aren't used when inputting the initial two numbers. However, since the numbers entered represent dollar figures, it would be nice to be able to use a comma.
2. I understand that the final two numbers in the addition command represent how many spaces are alloted for the answer and how many decimal places will be used. However, if we allot, say, 9 spaces for the answer but end up only using 5, there's a gap of four spaces between whatever comes before the code and the result of the code. For example, our answer might read something like this: $ 350.00. Is there a way to have the code use only as many spaces as necessary?
Neither of these are major issues, since the user can always edit the final letter to insert commas and delete extra spaces. However, having those operations completed automatically would be great.
Thanks,
Patrick
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
You can have A1-Law remove unwanted characters. The CHRTRAN function will change a group of characters from one thing to another.
Therefore:
chrtran("ABCDEFGHIJK", "BCD", "XYZ") will change all the B's to an X and all the C's to a Y and all the D's to a Z. Therefore:
chrtran("ABCDEFGHIJK", "BCD", "") will remove all the B's C's and D's. Therefore,
chrtran("12345,,,,,,,$$$$$$$,,,,6789", ",$", "") will remove all commas and dollar signs so it would return 123456789
Modifying the above code you could try the following to remove all dollar signs and commas before adding the numbers:
>
Mike
Therefore:
chrtran("ABCDEFGHIJK", "BCD", "XYZ") will change all the B's to an X and all the C's to a Y and all the D's to a Z. Therefore:
chrtran("ABCDEFGHIJK", "BCD", "") will remove all the B's C's and D's. Therefore,
chrtran("12345,,,,,,,$$$$$$$,,,,6789", ",$", "") will remove all commas and dollar signs so it would return 123456789
Modifying the above code you could try the following to remove all dollar signs and commas before adding the numbers:
>
Mike
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
In addition to my prior response for eliminating commas and dollar signs, you can eliminate spaces as follows:
Per your comment: For example, our answer might read something like this: $ 350.00. Is there a way to have the code use only as many spaces as necessary?
I would have to see your code but in general you would use the ALLTRIM to eliminate spaces:
>
Example: Total Fees: $>.
Mike
Per your comment: For example, our answer might read something like this: $ 350.00. Is there a way to have the code use only as many spaces as necessary?
I would have to see your code but in general you would use the ALLTRIM to eliminate spaces:
>
Example: Total Fees: $>.
Mike
-
Law Offices of George Henderson
- Posts: 107
- Joined: Thu Oct 23, 2008 1:31 pm
Re: Form Letters and Arithmetic Operations - Addition
on the command below, you have 12,2 at the end. What is that for?
>
>
-
Anonymous User
Re: Form Letters and Arithmetic Operations - Addition
It's part of the STR command where it is
STR(the number, total digits including decimal point, total digits to the right of the decimal point)
so 12,2 would allow for 9 digits to the left of the decimal point and 2 to the right (for cents).
Mike
STR(the number, total digits including decimal point, total digits to the right of the decimal point)
so 12,2 would allow for 9 digits to the left of the decimal point and 2 to the right (for cents).
Mike