<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFSCRIPT</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="説明">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFSCRIPT</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">説明</span>
<p>
cfscript ステートメントを含んでいるコードブロックを囲みます。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">カテゴリ</span>
<p>
アプリケーションフレームワークタグ、その他のタグ
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</span><pre>&lt;cfscript&gt; 
   ここに cfscript のコードを記述します。
&lt;/cfscript&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">関連項目</span>
<p>
cfinvoke、cfmodule、CreateObject、『ColdFusion MX 開発ガイド』の第6章の「CFML スクリプト言語を使用した ColdFusion ページの拡張」 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">ヒストリ</span>
<p>
ColdFusion&#160;MX: 
</p>
<ul>

<li>コンポーネントメソッドを呼び出す方法が変更されました。このタグで、CreateObject 関数を使用してコンポーネントメソッドを呼び出せるようになりました。</li>

<li>予約語の使い方が変更されました。このタグ内では ColdFusion の予約語は使用できません。</li>

<li>try ステートメントと catch ステートメントが追加されました。</li>
</ul>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">使用方法</span>
<p>
CFScript で処理を実行します。このタグでは、ColdFusion 関数、式、および演算子が使用されます。このタグ内で ColdFusion 変数の読み書きを行うことができます。 
</p>

<p>
CFScript のステートメント、および CFML タグに対応する CFScript のドキュメントを含めて、CFScript スクリプト言語の詳細については、『ColdFusion MX 開発ガイド』の第6章の「CFML スクリプト言語を使用した ColdFusion ページの拡張」 を参照してください。
</p>

<p>
cfscript タグを使用して、一連の代入ステートメントを囲むことができます。cfscript を使用しない場合は、cfset ステートメントが必要です。
</p>
<table>
  <tr valign="top">
    <td width="30"><strong>注意: </strong></td>
    <td>例外の Java クラス名を使用して、このタグ内で cftry/cfcatch ブロックをコーディングする場合は、完全修飾クラス名を指定する必要があります。 </td>
  </tr>
</table>
<p>
このタグ内では、一部の ColdFusion 予約語を使用できません。このタグ内に、次の文字列のいずれかで始まる名前のユーザー関数を挿入することはできません。 
</p>
<ul>

<li>cf</li>

<li>cf_</li>

<li>_cf</li>

<li>coldfusion</li>

<li>coldfusion_</li>

<li>_coldfusion</li>
</ul>

<p>
elseif コンストラクトを cfscript タグ内で使用することはできません。次のようなコードを使用できます。
</p>
<pre>else if ( condition )
{
...
}
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">cfscript タグでの例外処理</span>
<p>
このタグで例外を処理するには、try および catch ステートメントを使用します。これらは、cftry および cfcatch タグと同じ役割を果たします。各 try ステートメントについて、catch ステートメントが必要です。catch ブロックでは、変数 exceptionVariable に例外タイプが含まれます。この変数は、cfcatch タグのビルトイン変数 cfcatch.Type と同じ役割を果たします。詳細については、『ColdFusion MX 開発ガイド』の第6章の「CFML スクリプト言語を使用した ColdFusion ページの拡張」 を参照してください。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">cfscript タグを使用した ColdFusion コンポーネントの呼び出し</span>
<p>
CFScript では、CreateObject 関数を使用してコンポーネントメソッドを呼び出します。 
</p>

<p>
次の例では、cfscript タグを使用したコンポーネントオブジェクトの呼び出し方法を示します。この例では、指定された引数を使用します。
</p>
<pre>&lt;cfscript&gt;
quote = CreateObject( &quot;component&quot;, &quot;nasdaq.quote&quot; ) ;
&lt;!--- 指定された引数を使用した呼び出しです。 ---&gt;
res = quote.getLastTradePrice( &quot;macr&quot; ) ;
&lt;/cfscript&gt;
</pre>
<p>
次の例では、コンポーネントオブジェクトの呼び出し時に cfscript タグ内で属性コレクションを使用してパラメータを渡す方法を示します。属性コレクションは構造体です。この構造体では、各キーはパラメータ名に対応し、各値は対応するキーに渡されるパラメータの値となります。 
</p>
<pre>&lt;cfscript&gt;
   stArgs = structNew();
   stArgs.translationmode = &quot;en_es&quot;;
   stArgs.sourceData= &quot;Hello world, friend&quot;;
&lt;/cfscript&gt;
...
&lt;cfinvoke
   webservice = &quot;http://www.xmethods.net/sd/2001/BabelFishService.wsdl&quot;
   method     = &quot;BabelFish&quot;
   argumentCollection = &quot;#stArgs#&quot;
   returnVariable = &quot;varName&quot;   &gt; 
&lt;cfoutput&gt;#varName#&lt;/cfoutput&gt;   
</pre>
<p>
この例では、構造体は cfscript ブロックとして作成されますが、この構造体は任意の ColdFusion メソッドを使用して作成できます。 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">cfscript タグを使用した Web サービスの利用</span>
<p>
次の例では、cfscript タグを使用した Web サービスの利用方法を示します。Web サービスに接続するには、CreateObject 関数を使用します。
</p>
<pre>&lt;cfscript&gt;
   ws = CreateObject(&quot;webservice&quot;, 
            &quot;http://www.xmethods.net/sd/2001/BabelFishService.wsdl&quot;);
   xlatstring = ws.BabelFish(&quot;en_es&quot;, &quot;Hello world, friend&quot;);
   writeoutput(xlatstring);
&lt;/cfscript&gt;
</pre>
<p>
詳細については、『ColdFusion MX 開発ガイド』の第36章の「Web サービスの使用」 を参照してください。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">例</span><pre>&lt;p&gt;この簡単な例は、変数の宣言と操作を示します。
&lt;cfif IsDefined(&quot;form.myValue&quot;)&gt;
   &lt;cfif IsNumeric(form.myValue)&gt;
      &lt;cfset x = form.myValue&gt;
      &lt;cfscript&gt;
         y = x;
         z = 2 * y;
         StringVar = form.myString;
      &lt;/cfscript&gt;
   &lt;cfoutput&gt;      &lt;p&gt; #x# の 2 倍は #z# です。
      &lt;p&gt;文字列値。&lt;b&gt;&lt;I&gt;#StringVar#&lt;/i&gt;&lt;/b&gt;   &lt;/cfoutput&gt;
&lt;cfelse&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>

  </body>
</html>
