Copy link to clipboard
Copied
these are the formulas
3 separate cells
=ROUND((10^7.96427)*10^((-1628.445/(T24+273.15)))*10^((-100151/(T24+273.15)^2)),2)
=ROUND((10^7.96427)*10^((-1628.445/(T25+273.15)))*10^((-100151/(T25+273.15)^2)),2)
=(Y27-(0.00066*760*(T24-T25)*(1+(0.00115*T25))))/Y26
Thanks in advance
Copy link to clipboard
Copied
Yes they can. JavaScript uses the same symbols for the 4 basic arithmetic operations, uses the Math.exp() method for all exponentiation. JavaScript even includes the "if ... else" statement for conditional execution of blocks of code. Unlike Excel which has an error condition for division by zero, JavaScript does not, so one must test for a zero divisor and skip the action..
Copy link to clipboard
Copied
i unfortunately have no experience writing javascript.
i tired a in the example below but could not get the proper calculation
event.value=Math.exp((10^7.96427)*10^((-1628.445/(WBC+273.15)))*10^((-100151/(WBC+273.15)^2)),2)
event.value=Math.exp((10^7.96427)*10^((-1628.445/(DBC+273.15)))*10^((-100151/(DBC+273.15)^2)),2)
Y27-(0.00066*760*(T24-T25)*(1+(0.00115*T25))))/Y26
Where have i gone wrong?
Copy link to clipboard
Copied
ultimately i would like to calculate relative humidity from dry bulb and wet bulb temperature. there are a couple different ways to calculate, however can not get any proper calculation as i am javascript illiterate. attached original formulas and an excel sheet that does what i need (formulas imbedded)
https://www.sksato.co.jp/html_e/files/Psychrometer1.1E.xls
any help would be muchly appreciated.
Copy link to clipboard
Copied
First of all, check the JS Console and you'll see some error messages. The first one will be probably be something like this:
ReferenceError: WBC is not defined
1:Console:Exec
That happens because there's no variable called WBC. You can't access the value of a field directly. You need to use the getField method, and then the value property, like this:
var WBC = this.getField("WBC").value;
And if you want to make sure it's a number, use this:
var WBC = Number(this.getField("WBC").value);
Make those changes and try again. Check if there still error messages in the Console, and repeat...
Copy link to clipboard
Copied
Did you read the linked description for the Math.exp?
You might want to use the Math.pow() method.
Syntax
Math.pow(base, exponent)
Parameters
base
The base number.
exponent
The exponent used to raise the base.
Return value
A number representing the given base taken to the power of the given exponent.
Copy link to clipboard
Copied
thank you for this but it looks like its way over my head, anyone care to take a crack at it?
i will try my best to post existing formulas from excel with explainations
will be calculated from 3 separate text fields
text field - es
=ROUND((10^7.96427)*10^((-1628.445/(dbr+273.15)))*10^((-100151/(dbr+273.15)^2)),2)
text field - ew
=ROUND((10^7.96427)*10^((-1628.445/(wbr+273.15)))*10^((-100151/(wbr+273.15)^2)),2)
text field - e
=(es-(0.00066*760*(dbr-wbr)*(1+(0.00115*wbr))))/ew
text fields dbr and wbr could have any number between 0 to 130
any help would be great!
thanks in advance
Copy link to clipboard
Copied
You are clearly not writing JavaScript. JavaScript is an object orientated language. That means you have an object and that object can have various properties beyond the value. So you cannot write code as one does within a cell in Excel. I have looked at your locked worksheet and the formulas that you have posted. It is clear the data used in your formulas is coming from cells that I cannot view.
There free and pay for resources for learning JavaScript for Acrobat.