* calculate in forms
@ 1999-12-20 14:48 Haseloff, Lutz
1999-12-20 15:54 ` Hans Hagen
1999-12-22 21:47 ` Hans Hagen
0 siblings, 2 replies; 4+ messages in thread
From: Haseloff, Lutz @ 1999-12-20 14:48 UTC (permalink / raw)
Hi all, Hi Hans,
I want to prepare a form with calculating fields.
My file looks like this:
.....
\startJScode{Format}
AFNumber_Format(2, 3, 0, 0, "", true);
\stopJScode
\startJScode{Keystroke}
AFNumber_Keystroke(2, 3, 0, 0, "", true);
\stopJScode
\startJScode{Calculate}
AFSimple_Calculate("SUM", new Array ("Summand1", "Summand2"));
\stopJScode
.......%%% I use the Scripts from AForm.js because my JS programming is poor
\setupfield
[ErgSetup]
[frame=on,width=8cm,height=4ex,format=JS(Format),afterkey=JS(Keystroke),calc
ulate=JS(Calculate)]
........
\hbox to 11cm{Summand 2:\hfill \field[Summand2]}
\hbox to 11cm{Ergebnis :\hfill \field[Ergebnis]}
...........
All scripts are at the right places in the pdf-file (tested with Acrobat)
and the format and afterkey
scripts work very fine.
Only the calculation does not work.
Is it possible that the missing "/CO [...]" near /Fields is the Reason?
In the PDF Specification the "Calculate Order" is required.
Greetings
Lutz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: calculate in forms
1999-12-20 14:48 calculate in forms Haseloff, Lutz
@ 1999-12-20 15:54 ` Hans Hagen
1999-12-22 21:47 ` Hans Hagen
1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 1999-12-20 15:54 UTC (permalink / raw)
Cc: ntg-context
At 03:48 PM 12/20/99 +0100, Haseloff, Lutz wrote:
>I want to prepare a form with calculating fields.
>My file looks like this:
>.....
>\startJScode{Format}
>AFNumber_Format(2, 3, 0, 0, "", true);
>\stopJScode
>\startJScode{Keystroke}
>AFNumber_Keystroke(2, 3, 0, 0, "", true);
>\stopJScode
>\startJScode{Calculate}
>AFSimple_Calculate("SUM", new Array ("Summand1", "Summand2"));
>\stopJScode
>.......%%% I use the Scripts from AForm.js because my JS programming is poor
>\setupfield
> [ErgSetup]
>
>[frame=on,width=8cm,height=4ex,format=JS(Format),afterkey=JS(Keystroke),calc
>ulate=JS(Calculate)]
>........
>\hbox to 11cm{Summand 2:\hfill \field[Summand2]}
>
>\hbox to 11cm{Ergebnis :\hfill \field[Ergebnis]}
>...........
>
>All scripts are at the right places in the pdf-file (tested with Acrobat)
>and the format and afterkey
>scripts work very fine.
>Only the calculation does not work.
>
>Is it possible that the missing "/CO [...]" near /Fields is the Reason?
>In the PDF Specification the "Calculate Order" is required.
Hm. I'll have to look into that. At our site there is a demo using
calculations: travel. You could take a look at that too check.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: calculate in forms
1999-12-20 14:48 calculate in forms Haseloff, Lutz
1999-12-20 15:54 ` Hans Hagen
@ 1999-12-22 21:47 ` Hans Hagen
1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 1999-12-22 21:47 UTC (permalink / raw)
Cc: ntg-context
Hi Lutz,
>All scripts are at the right places in the pdf-file (tested with Acrobat)
>and the format and afterkey
>scripts work very fine.
>Only the calculation does not work.
For proper testing I need a complete file.
>Is it possible that the missing "/CO [...]" near /Fields is the Reason?
>In the PDF Specification the "Calculate Order" is required.
I wonder if this entry is really needed. I want to test it first.
This calculate thing is rather fuzzy. It's often best to do it manually,
i.e. code it.
\startJSpreamble {Calculate} used now
function Calculate ()
{ v = getField("Ergebnis") ; v.value = 0 ;
v.value += getField("Summand1").value ;
v.value += getField("Summand2").value }
\stopJSpreamble
\startJScode{Format}
AFNumber_Format(2, 3, 0, 0, "", true) ; Calculate() ;
\stopJScode
\startJScode{Keystroke}
AFNumber_Keystroke(2, 3, 0, 0, "", true) ; Calculate() ;
\stopJScode
In due time I will cook up some proper auxiliary functions.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: calculate in forms
@ 1999-12-28 10:19 Haseloff, Lutz
0 siblings, 0 replies; 4+ messages in thread
From: Haseloff, Lutz @ 1999-12-28 10:19 UTC (permalink / raw)
Cc: ntg-context
Hi Hans, Hi all,
> \startJSpreamble {Calculate} used now
> function Calculate ()
> { v = getField("Ergebnis") ; v.value = 0 ;
> v.value += getField("Summand1").value ;
> v.value += getField("Summand2").value }
> \stopJSpreamble
This treats the values like strings if they contain other seperators as a
dot
I changed your solution to:
\startJSpreamble {Calculate} used now
function Calculate ()
{ v = getField("Ergebnis") ; v.value = 0 ;
v.value += AFMakeNumber(getField("Summand1").value) ;
v.value += AFMakeNumber(getField("Summand2").value) }
\stopJSpreamble
and this works very nice for me.
Thank you very much
Happy New Year
Lutz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-12-28 10:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-20 14:48 calculate in forms Haseloff, Lutz
1999-12-20 15:54 ` Hans Hagen
1999-12-22 21:47 ` Hans Hagen
1999-12-28 10:19 Haseloff, Lutz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).