Actions

Translations

ExpressionScript How-tos/13/ja: Difference between revisions

From LimeSurvey Manual

(Created page with "EM式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。 #中括弧の後にスペース...")
 
No edit summary
 
Line 1: Line 1:
EM式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。
ES式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。
#中括弧の後にスペースを追加し忘れたインラインJavascript
#中括弧の後にスペースを追加し忘れたインラインJavascript
#*"document.write"が中括弧の直後に表示されると、EMはそれを式と見なし、"document"と"write"はそれぞれ未定義の変数と関数と認識され、赤いボックス内に表示されます。
#*"document.write"が中括弧の直後に表示されると、EMはそれを式と見なし、"document"と"write"はそれぞれ未定義の変数と関数と認識され、赤いボックス内に表示されます。
Line 13: Line 13:
#*ここでは、閉じ括弧が不足している例2つと、閉じ括弧が多すぎる例を示しています。
#*ここでは、閉じ括弧が不足している例2つと、閉じ括弧が多すぎる例を示しています。
#サポートされていない構文
#サポートされていない構文
#*EMがサポートしていない演算子や記号を使用すると、赤いボックスで囲まれます。
#*ESがサポートしていない演算子や記号を使用すると、赤いボックスで囲まれます。
#無効な代入
#無効な代入
#*変数には、読み書き可能で値を変更できるもの、読み取り専用のものがあります。
#*変数には、読み書き可能で値を変更できるもの、読み取り専用のものがあります。
#*読み取り専用変数の値を変更しようとしてもできません。この場合、EMは赤いボックスで表示します。
#*読み取り専用変数の値を変更しようとしてもできません。この場合、EMは赤いボックスで表示します。
#*式または文字列に値を代入しようとしてもエラーが発生します。
#*式または文字列に値を代入しようとしてもエラーが発生します。

Latest revision as of 01:01, 22 May 2020

Message definition (ExpressionScript How-tos)
Here are examples of common errors when typing ES expressions. Note that the tooltips provide additional information.
#Inline Javascript that forgot to add spaces after curly brace
#*Since "document.write" appears right after a curly brace, EM thinks it is an expression, and red-boxes "document" and "write" since they are undefined variable and functions, respectively
#Unknown/Misspelled variables, functions and operators
#*Here we forgot that we are using the variable name "gender" instead of "sex", but EM catches that error. It also red-boxes '++', since that is not a supported operator.
#Warns if use = instead of eq, or perform value assignments
#*Note that the '=' and '+=' are in red text instead of black. If you hover the mouse over them, you will see warnings that you are assigning a value.
#Wrong number of arguments for functions
#*if() takes 3 arguments, but it has been given 4, so hovering over the red-boxed "if" will explain the error and show the supported syntax
#*sum() takes an unlimited number of arguments, but we had a trailing comma before the closing parentheses, so that is red-boxed
#Mismatched parentheses
#*This is one of the most common errors when writing expressions.
#*This shows two examples of missing closing parentheses, and one example of having one too many closing parentheses.
#Unsuported syntax
#*If you use an operator or punctuation that ES does not support, it will red-box it.
#Invalid assignments
#*Some variables are readWrite and can have their values changed. Others are read-only.
#*If you try to change the value of a read-only variable, you can't. EM will red-box the attempt.
#*If you try to assign a value to an equation or a string, you will also get an error

ES式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。

  1. 中括弧の後にスペースを追加し忘れたインラインJavascript
    • "document.write"が中括弧の直後に表示されると、EMはそれを式と見なし、"document"と"write"はそれぞれ未定義の変数と関数と認識され、赤いボックス内に表示されます。
  2. 不明、またはスペルミスのある変数、関数、演算子
    • ここでは、"sex"ではなく"gender"という変数名を誤って使用していても、EMはそのエラーをキャッチします。また、'++'はサポートされている演算子ではないため、赤いボックスで囲まれます。
  3. eqの代わりに=を使用したり、値を代入すると警告されます。
    • '='と'+='は、黒ではなく赤のテキストで表示されています。その上にマウスカーソルを合わせると、値を代入している旨の警告が表示されます。
  4. 関数の引数の数の誤り
    • if()は3つの引数を受け取りますが、4つ与えられているため、赤い枠で囲まれた"if"にカーソルを合わせると、エラーの説明とサポートされている構文が表示されます。
    • sum()は引数の数に制限はありませんが、閉じ括弧の前にコンマがあるため、赤いボックスで囲まれています。
  5. 括弧の不一致
    • これは、式を記述する際の最も一般的なエラーの1つです。
    • ここでは、閉じ括弧が不足している例2つと、閉じ括弧が多すぎる例を示しています。
  6. サポートされていない構文
    • ESがサポートしていない演算子や記号を使用すると、赤いボックスで囲まれます。
  7. 無効な代入
    • 変数には、読み書き可能で値を変更できるもの、読み取り専用のものがあります。
    • 読み取り専用変数の値を変更しようとしてもできません。この場合、EMは赤いボックスで表示します。
    • 式または文字列に値を代入しようとしてもエラーが発生します。