The Artima Developer Community
Sponsored Link

Java Answers Forum
Need math script help

5 replies on 1 page. Most recent reply: Oct 2, 2003 5:56 PM by J Stevens

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
J Stevens

Posts: 6
Nickname: cryslyn
Registered: Oct, 2003

Need math script help Posted: Oct 2, 2003 1:01 PM
Reply to this message Reply
Advertisement
I'm putting together a .pdf file in Adobe Acrobat, and making a 'Fill & Print' form. The form needs to figure some numbers. I can get most of it, but not all. Here is what I want to do:
5 variables = var a, b, c, d, e
var a = first number
var b = second number
var c = third number
var d = fourth number
var e = '-' or '+' in a box
if the '-' is in the box, then the equation will be:
event.value = a.value - b.value + c.value + d.value

if there is nothing in the box, or a '+' then it would be:
event.value = a.value + b.value + c.value + d.value

im thinkin maybe an if then type ?? someone help? thanks


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: Need math script help Posted: Oct 2, 2003 3:18 PM
Reply to this message Reply
I really don't get what you're trying to do - I didn't even know that any computation could be done from within a PDF file.

Unless I've missed something, why are you posting this on a Java forum?

J Stevens

Posts: 6
Nickname: cryslyn
Registered: Oct, 2003

Re: Need math script help Posted: Oct 2, 2003 4:02 PM
Reply to this message Reply
Yes, you can use Java in adobe acrobat pdf files. I made a form in there to compute a tax account. here's what i've done, but it doesnt seem to work.

here's what i want to do. number 1
-/+
chart looks like that ----> number 2
number 3
number 4
total

if '+' sign or no sign is used in the space for it, number1 + number2 + number3 + number4 = total

if '-' sign is used, then number1 - number2 + number3 + number4 = total


any suggestions? i tried this;

var a = this.getField ("2");
var b = this.getField ("3");
var c = this.getField ("4");
var d = this.getField ("5");
var e = this.getField ("7");

if (e.value = "-"){
event.value = a.value - b.value + c.value + d.value;
}
else {
event.value = a.value + b.value + c.value + d.value;
}

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Need math script help Posted: Oct 2, 2003 4:54 PM
Reply to this message Reply
What you have posted is definitely not Java, but it looks a lot like JavaScript. I guess this is this some kind of scripting or macro capability offered by Adobe? In any case, as far as the simple computation and logic goes, if you are on the Windows platform you can do that experimentation in a separate JS file; once you get it working as you like, then you can use it in the Adobe environment (or file, or whatever it is). You can get documentation for JScript (and VBScript -- generally for Windows Scripting) at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoriJScript.asp (if this url doesn't work, just go to http://msdn.microsoft.com and search for "Scripting").

I don't know what you mean by "doesn't seem to work" but the above should help you figure out any JScript-related issues. That doesn't really help much with the interface to Adobe's stuff (although it kind of looks like standard web page stuff, not Adobe specific); if Adobe supports WSH as their scripting engine, then I'd guess that they've documented it (probably in PDF).

J Stevens

Posts: 6
Nickname: cryslyn
Registered: Oct, 2003

Re: Need math script help Posted: Oct 2, 2003 5:21 PM
Reply to this message Reply
Ok, well, according to the Adobe program, it is Java 1.5 script. All I was wanting to know how to do, was to take a number, either add or subtract from it, then add two more numbers. The key to the script, is whether you put a minus sign or a plus sign or a blank in the form. If you put minus, it subtracts the second number from the first, then adds the other two. If you put a plus or leave blank, it adds the second number to the first, then adds the other two as well. Thanks. J

J Stevens

Posts: 6
Nickname: cryslyn
Registered: Oct, 2003

Re: Need math script help Posted: Oct 2, 2003 5:56 PM
Reply to this message Reply
Thanks for your help. Here is the fix. :)

var a = this.getField ("2");
var b = this.getField ("3");
var c = this.getField ("4");
var d = this.getField ("5");
var e = this.getField ("7");

if (e.value == "-")
event.value = a.value - b.value + c.value + d.value;

else
event.value = a.value + b.value + c.value + d.value;

Flat View: This topic has 5 replies on 1 page
Topic: 'External' in SQL Loader Ctrl file Previous Topic   Next Topic Topic: RMI doubt

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use