This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calculation. .................... Please Help

 
Joel Ogbueli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Could somebody help me out on translate the following cal.
formula to java function (in array)

1.)
If IsNull(x_LowOperatingRange.value) OR x_LowOperatingRange.value = "NA"
OR ((InStr(x_DeviceID.value, "PSH") > 0) And x_HighOperatingRange.value
<= 30 Then
PRE_SetPointPressure_.value + 5
ElseIf ((InStr(x_DeviceID.value, "PSH") > 0) And Round(x_HighOperatingRange.value * 1.15,0) > x_MAWP.value * 0.95 Then
PRE_SetPointPressure_.value = x_MAWP.value * 0.95
ElseIf ((InStr(x_DeviceID.value, "PSH") > 0) Then
PRE_idSetPointPressure_.value = Round(1.15 * x_HighOperatingRange.value,0)
ElseIf IsNull(x_LowOperatingRange.value) OR x_LowOperatingRange.value = "NA" OR ((InStr(x_DeviceID.value, "PAH") > 0) And Round(1.075 * x_HighOperatingRange.value,0) > 0.95 * x_MAWP.value Then
PRE_idSetPointPressure_.value = x_MAWP.value * 0.95
ElseIf ((InStr(x_DeviceID.value, "PAH") > 0) Then
PRE_SetPointPressure_.value = Round(1.075 * x_HighOperatingRange.value,0)
ElseIf IsNull(x_HighOperatingRange.value) OR x_LowOperatingRange.value
= "NA" OR ((InStr(x_DeviceID.value, "PSL") > 0) And x_LowOperatingRange.value <= 30 Then
PRE_SetPointPressure_.value = x_LowOperatingRange.value - 5
ElseIf ((InStr(x_DeviceID.value, "PSL") > 0) And x_LowOperatingRange.value
>= 31 Then
PRE_SetPointPressure_.value = Round(x_LowOperatingRange.value * 0.85,0)
ElseIf IsNull(x_HighOperatingRange.value) OR x_LowOperatingRange.value = "NA" OR ((InStr(x_DeviceID.value, "PSH") > 0) Then
PRE_SetPointPressure_.value = Round(0.925 * x_LowOperatingRange.value,0)
End If
Thanxs in advance
 
Joel Ogbueli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please could anybody help me with Array....... I am so confused

function calculation(){
if( !x_LowOperatingRange.value || x_LowOperatingRange.value==="NA" || (x_DeviceID.value.match("PSH")) && x_HighOperatingRange.value <= 30) {
PRE_SetPointPressure_.value + 5;
}
else if(x_DeviceID.value.match("PSH")) && Math.floor(x_HighOperatingRange.value) * 115/100) > x_MAWP.value * 0.95) {
PRE_SetPointPressure_.value = x_MAWP.value * 0.95;
}
else if(x_DeviceID.value.match("PSH")) {
PRE_idSetPointPressure_.value = Math.floor(x_HighOperatingRange.value) * 115/100);
}
if( !x_LowOperatingRange.value || x_LowOperatingRange.value==="NA" || (x_DeviceID.value.match("PAH")) && Math.floor(x_HighOperatingRange.value)*107.5/100) > 0.95 * x_MAWP.value) {
PRE_idSetPointPressure_.value = x_MAWP.value * 0.95;
}
else if(x_DeviceID.value.match("PAH")) {
PRE_SetPointPressure_.value = Math.floor(x_HighOperatingRange.value)*107.5/100);
}
if( !x_x_HighOperatingRange.value || x_HighOperatingRange.value==="NA" || (x_DeviceID.value.match("PSL")) && x_LowOperatingRange.value <= 30) {
PRE_SetPointPressure_.value = x_LowOperatingRange.value - 5;
}
else if(x_DeviceID.value.match("PSL")) && x_LowOperatingRange.value >= 31) {
PRE_SetPointPressure_.value = Math.ceil(x_LowOperatingRange.value)*85/100);
}
if( !x_x_HighOperatingRange.value || x_x_HighOperatingRange.value==="NA" || (x_DeviceID.value.match("PAL"))) {
PRE_SetPointPressure_.value = Math.ceil(x_LowOperatingRange.value)*92.5/100);
}
}
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have three equal signs in a row
_LowOperatingRange.value==="NA"
should be 2
 
Joel Ogbueli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please anybody help out on how to echo Ext_Record_count (record count Number) into the below function from the form

function calculation() {
for (num=0; num< <%=Ext_Record_Count%>; num++) {
if( !x_LowOperatingRange.value || x_LowOperatingRange.value=="NA" || (document.getElementById('PRE_DEVICEID_'+num).value.match("PSH")) && x_HighOperatingRange.value <= 30) {
document.getElementById('PRE_SetPointPressure_'+num).value + 5;
}
else if(document.getElementById('PRE_DEVICEID_'+num).value.match("PSH")) && Math.floor(x_HighOperatingRange.value) * 115/100) > x_MAWP.value * 0.95) {
document.getElementById('PRE_SetPointPressure_'+num).value = x_MAWP.value * 0.95;
}
else if(document.getElementById('PRE_DEVICEID_'+num).value.match("PSH")) {
document.getElementById(PRE_SetPointPressure_.value = Math.floor(x_HighOperatingRange.value)) * 115/100);
}
if( !x_LowOperatingRange.value || x_LowOperatingRange.value=="NA" || (document.getElementById('PRE_DEVICEID_'+num).value.match("PAH")) && Math.floor(x_HighOperatingRange.value)*107.5/100) > (0.95 * x_MAWP.value)) {
document.getElementById('PRE_SetPointPressure_'+num).value = x_MAWP.value * 0.95;
}
else if(document.getElementById('PRE_DEVICEID_'+num).value.match("PAH")) {
document.getElementById('PRE_SetPointPressure_'+num).value = Math.floor(x_HighOperatingRange.value)*107.5/100);
}
if( !x_HighOperatingRange.value || x_HighOperatingRange.value=="NA" || (document.getElementById('PRE_DEVICEID_'+num).value.match("PSL")) && x_LowOperatingRange.value <= 30) {
document.getElementById('PRE_SetPointPressure_'+num).value = x_LowOperatingRange.value - 5;
}
else if(document.getElementById('PRE_DEVICEID_'+num).value.match("PSL")) && x_LowOperatingRange.value >= 31) {
document.getElementById('PRE_SetPointPressure_'+num).value = Math.ceil(x_LowOperatingRange.value)*85/100);
}
if( !x_HighOperatingRange.value || x_HighOperatingRange.value=="NA" || (document.getElementById('PRE_DEVICEID_'+num).value.match("PAL"))) {
document.getElementById('PRE_SetPointPressure_'+num).value = Math.ceil(x_LowOperatingRange.value)*92.5/100);
}
}
}
This is the form
*************
<tr id="trow_<%=Ext_Record_Count%>" name="ntrow_<%=Ext_Record_Count%>">
<td class="data" height="58" bgcolor="#F5F5F5"> <input type="text" id="PRE_idDEVICEID_<%=Ext_Record_Count%>" name="PRE_DEVICEID_<%=Ext_Record_Count%>" value="<%=trim(Rs_Ext("DEVICEID")) %>" size=15 maxlength=10>
</td>
<td class="data" bgcolor="#F5F5F5"> <input type="text" id="PRE_idSETPOINTPRESSURE_<%=Ext_Record_Count%>" name="PRE_SETPOINTPRESSURE_<%=Ext_Record_Count%>" value="<%=trim(Rs_Ext("SETPOINTPRESSURE")) %>"size=6 maxlength=8>
</td>
<td class="data" bgcolor="#F5F5F5"> <input type="text" id="PRE_idFOUNDPRESSURE_<%=Ext_Record_Count%>" name="PRE_FOUNDPRESSURE_<%=Ext_Record_Count%>" value="<%=trim(Rs_Ext("FOUNDPRESSURE")) %>" size=6 maxlength=8>
</td>
<td class="data" bgcolor="#F5F5F5"> <input type="text" id="PRE_idLEFTPRESSURE_" name="PRE_LEFTPRESSURE_<%=Ext_Record_Count%>" value="<%=trim(Rs_Ext("LEFTPRESSURE")) %>" size=6 maxlength=8 onBlur="CyJS_Utils_isNumber(this);">
</td>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic