These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Number scripting in Acrobat 6

joshuablack
Registered: May 23 2007
Posts: 2

I have text fields created on a form in Acrobat Pro 6. The forms are supposed to take the Friday "week ending date" and subtract one day for each preceding day of the week. the problem is that when the ending day is friday the 1st, the preceeding days go into negative numbers. What I would like to do is use if/then statemens so that if Friday = 1, then thursday will = 30, but if friday = 10 then Thursday will = 9. Do you have resources for learning this scripting for Acrobat.

My Product Information:
Acrobat Pro 6.0.5, Windows
dthanna
ExpertTeam
Registered: Sep 28 2005
Posts: 248
If you are trying to build an arbritrary system, you first have to know what Month and Year under discussion. A simple 12 cell array is sufficient to keep track of the months (cell 1 = Jan w/ a val of 31, cell 2 = Feb (which we will skip for now), 3 = March w/ a val of 31 etc. We'll call this arMonth[1..12] Your general logic then becomes, if Date=1 and Day=Fri, then DayThurs=arMonth[curMonth-1]. DayWed=arMonth[curMonth-1] - 1. Etc. To speed things up, you can pull the value out of the array into a variable and just sub one off it it as you work backwards.

Feb is that lovely special case, and so if Friday, March 1 is in order, to find Thursday, you first need to determine if it was a leap-year or not (check wikipedia on leap year formula - modulus 400 should be sufficient for most work). Once you know that, you know whether Feb had 28 or 29 days. Plug that into the array then continue on as before.

Another method, if leap year calcs get confusing, is just to have another array with the leap years. Cell #1 needs to be some known year (Note it in the comments!!!) - then each successive cell is a binary value True (leap year) False (not a leap year). You perform the lookup as a subtractive offset. CurYear - BaseYear = array offset. Simple if/then to populate your Month array with the correct value and continue on your merry way.

There shouldn't be any limitations in JS to perform this (the most complicated thing is the Modulus operator), it's just that functions like this generally don't exist in most languages - so you build your own, but don't reinvent the wheel.

A couple of Google searches will come up with a wealth of logic dealing with this issue.

Good luck!

Douglas Hanna is a member of the Production Print Technology team at Aon.
www.aonhewitt.com