FormSprint Newsletter
by ICS, Inc.
December 2007
In This Issue
Math Function Examples
It All Adds Up
Math Function Examples
Example11282: Using the MATH function to add a column and subtotal
Quick Links
Join Our Mailing List
Greetings!

Merry Christmas and Happy holidays to one and all! All of us at ICS wish all of you a healthy, happy and prosperous New Year!

This month we thought we would talk about several of the ways in which FormSprint can be used for math functions. Remember, as you read over the ideas, it all adds up to a more effective and professional looking form! Have fun with the math ideas!

 
It All Adds Up

FormSprint's math function is one of the most powerful of the many functions included with the program.     FN(MA,*,n,#,.##)

You can use this command for any of the four basic math functions, addition (+), subtraction (-), multiplication (*), and division (/). The following are a few examples of what you could do by using the math function. Also, you will find a couple of sample forms to download on the left so that you can see what the coding might look like.

'Twas the night before Christmas, when all through the house
Not a column was added not even a ..'

Need to add a column of numbers? No problem! The only challenge in doing this with FormSprint is that when adding a column, blank lines must be eliminated or zero filled. This can be easily done by pre-loading a buffer line with zero (0) and then propagating the zeros to fill a series of buffer lines long enough to take all the lines you need to add. Then, when the column to be added is loaded to the buffers,  (R)EPLACE  is used to replace only the lines that contain data you want to add.

Sometimes the column total needs to be carried forward from one page to another. To do this, we save the subtotal using memory and then clear memory whenever the page number begins again at page one. Please see the sample form to see this coding.

'The stockings were hung by the chimney with care,
In hopes that the currency conversion soon would be there.'


Currency conversion?? Sure! By using the multiplication feature in the math function, and by adding a conversion factor to a Substitution Table (or how about right in the spool file?) you could easily convert your numeric field from say, US to Canadian or whatever.

'The children were nestled all snug in their beds,
While visions of percentages danced in their heads;'


Sure, doesn't everyone dream about being able to calculate percentages with their forms software! This is a pretty simple task when using the multiplication feature of the math function. The percentage (20%, 30%, 75%...) could be hard coded into the function, or it could be a variable loaded from the spool file into a buffer or loaded from a Substitution Table into a buffer. This would be the format if the operand is loaded into a buffer:    FN(MA,*,B2,#) where buffer 2 contains the percentage.

'And mamma in her 'kerchief', and I in my cap, were scratching our heads to make the first page print last.'

Uh, last page first, first page last? It's one of those things that you won't be asked to do everyday, but when you need it, you need it! FormSprint's PG (page number) function can be used to keep a page count. By using the division feature in the math function, you can calculate the reciprocal of the page count.  This in turn can be used as the sort criteria in a dynamic distribution function...and the first shall be last!

'Now, Dasher! now, Dancer! Now Prancer and Vixen!
On commas, and decimals! On dollar signs and Blitzen!'


OK, OK, what we're trying to say is that you can use the math function to re-format your numeric fields. To do this, multiply your field by one (1) and then use the formatting parameter to put in the commas, decimals, and/or dollar signs.

            FN(MA,*,1,$#,.##)

'And then, in a twinkling, I heard on the roof
The prancing and pawing of each little hoof, trying to calculate a date in the future.'


Yes, you can either increment or decrement a date by a given number of days by using the Math Date function:     FN(MD,d) where d is the number of days to increment or decrement. Beginning with the date in YYYYMMDD format, you can return a date in the same format or use the buffers to re-arrange and then, the day function (FN(DA,1)) to return the date in many other formats  like: Tues December 25, 2007!

'But I heard him exclaim, ere he drove out of sight, FormSprint's the Best and to All a good-night!....and Happy Christmas too!'

 
Merry Christmas Y'all,
 Betsy AndrewsICS logo

Betsy Andrews
Integrated Custom Software, Inc.
Integrated Custom Software, Inc. | 12 National Drive | Glastonbury | CT | 06033