2013-05-13 155 views
0

具有用下面的代碼語法錯誤的問題在線路11,12,13,「如果」「其他」與語法錯誤

// Get the field values 
var DP = +getField("DESIGN_Projection").value; 
var TC = +getField("ASBUILT_Top_of_Concrete").value; 
var GE = +getField("ASBUILT_Ground_Elevation").value; 



// If DP is N/A, set this field to display N/A 
If (DP === N/A); { 
    event.value = "NA"; // display N/A in this field 
} else 
{ 
    //...otherwise, set this field value to the result of the following calculation 
    event.value = ((TC - GE) * 1000);  
} 
+1

這不是java嗎?它看起來像JavaScript。 – FDinoff 2013-05-13 20:48:11

回答

0

Ifif(小寫ⅰ)語句

另外從if中刪除;

if (DP === N/A) { 
    event.value = "NA"; // display N/A in this field 
} else 
0

if語句結尾處有分號。

if也應該是小寫

2

你有幾個問題,與這條線:

If (DP === N/A); { 

首先,請注意If應該是小寫(if)。其次,請注意在if聲明後面有一個分號。這使得語言認爲你的代碼應該被解釋爲

If (DP === N/A) 
    ; // Do nothing 

{ 
    event.value = "NA"; // display N/A in this field 
} else 
{ 
    //...otherwise, set this field value to the result of the following calculation 
    event.value = ((TC - GE) * 1000);  
} 

由此看來,它應該是更清楚的錯誤是什麼 - 有一個神祕的else左右浮動!

如果刪除分號並將If更改爲if,則錯誤應該消失。

希望這會有所幫助!

+0

if語句的基本設置很簡單:「if(){something;} – ObedMarsh 2013-05-13 20:49:38