Is it possible for acrobat to reference a data table and get a value? Let me explain:
Score=Modifier
1=-5
2-3=-4
4-5=-3
6-7=-2
8-9=-1
10-11=0
12-13=+1
14-15=+2
16-17=+3
18-19=+4
What I'm looking to do is try and automate a character sheet in acrobat. I have six fields named STR, CON, DEX, INT, WIS, and CHA. Each of these fields have a corresponding bonus field STR_Bonus, etc, etc... Unfortunately, I'm not smart enough to come up with a formula capable of providing the correct bonus based on the entered score. The score can go to any height, but realistically could be capped at 50.
I'm hoping that there could be some way that a data field/table field could be created that the STR_bonus field would reference to look up the bonus gained from the user entered Ability Score entered in the STR field.
I'm creating my forms in LiveCycle, but I also have Acrobat Pro that I can use to insert scripts.
// Set up JavaScript array to associate score value
// with a modifier value
var modifier_array = [0, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4];
Now, to look up the modifier given the score, you could do something like:
var modifier = modifier_array[score];
Note that I set the vale of the first item of the array to zero. The first item of an array has an index of zero, but since you did not list a score of zero in your table above, I just gave it a dummy value. If a score of zero is a valid score, you'd use whatever modifier value is appropriate.
George