次のようなケース処理を追加することで、エラー メッセージをより明確にすることができます。
function in2mm(inNum) {
// Function to convert from INCHES to MILLIMETERS
var outNum = 0; // this will hold the answer
var factor = 25.4; // multiply input by this factor to get output
if (inNum == "") { // check to make sure input is a number
throw ("error: input must not be empty"); // throw an exception with the error message
}else if (typeof inNum != "number") { // check to make sure input is a number
throw ("error: input must be a number (now it is a "+typeof inNum+")"); // throw an exception with the error message
}
outNum = inNum * factor; // calculate the answer
return outNum; // return the answer to the cell which has the formula
}
しかし、引数は関数によって処理されるために「有効」である必要があります...あなたの例=in2mm(a)
では、aは名前付き領域として解釈され、「a」という領域がないため、実行しようとする前にエラーが発生します関数。そのため、エラー メッセージは関数自体からではなく、スプレッドシートの下の「エンジン」からのものです。
他の例=in2mm(*)
では、同じ理由で解析エラーが返されます。引数が有効ではなく、この場合は範囲にすることもできません... + または - を試すこともできます。何かを計算しようとしますが、できません。エラーメッセージは、関数からではなく、スプレッドシートからのものです。
有効な範囲を使用してターゲット セルの値を変更してみてください。まったく異なる結果が表示されます。たとえば、A2
write=in2mm(A1)
と play でA1
私が物事を(少し)より明確にしたことを願っています;-)