Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

<case>

<switch> 要素内で条件が一致した場合に、一連のアクティビティを実行します。

Synopsis

<switch>   <case>     ...   </case>    ...   <default>     ...   </default> </switch>

詳細

属性または要素 説明
condition 属性 必須項目。この式の結果が真の場合、この <case> 要素の内容が実行されます。偽の場合、この <case> 要素は無視されます。 整数値 1 (真の場合) または 0 (偽の場合) を求める式。この式では、この属性が含まれる <process> 要素で指定されているスクリプト言語を使用する必要があります。
namedisabledxposyposxendyend 属性 一般的な属性と要素” を参照してください。  
<annotation> 要素
その他の要素 オプション。<case> には、<alert>、<assign>、<branch>、<break>、<call>、<code>、<continue>、<delay>、<empty>、<flow>、<foreach>、<if>、<label>、<milestone>、<reply>、<rule>、<scope>、<sequence>、<sql>、<switch>、<sync>、<throw>、<trace>、<transform>、<until>、<while>、<xpath> および <xslt> をゼロ個以上、自由に組み合わせて使用できます。  

説明

<switch> 要素には、連続する 1 つ以上の <case> 要素と、オプションの <default> 要素が含まれます。

<switch> 要素が実行されると、さらに各 <case> 条件が評価されます。これらの条件は、それを含む <process> 要素のスクリプト言語で記述された論理式です。いずれかの式の結果が整数値 1 (真) の場合、それに対応する <case> 要素の内容が実行されます。それ以外の場合は、次の <case> 要素の式が評価されます。

どの <case> 条件も真でない場合は、<default> 要素の内容が実行されます。

いずれかの <case> 要素が実行されるとすぐに、対応する <switch> 文から実行制御が離れます。どの <case> 条件も一致しない場合は、<default> アクティビティを実行した後で <switch> から制御が離れます。

<case> 要素内では、いずれかの BPL アクティビティを使用できます。例えば、以下の例では <assign> 要素が使用されています。

<switch name='Approved?'>
  <case name='No PrimeRate' condition='context.PrimeRate=""'>
    <assign name='Not Approved' property="response.IsApproved" value="0"/>
  </case>
  <case name='No Credit' condition='context.CreditRating=""'>
    <assign name='Not Approved' property="response.IsApproved" value="0"/>
  </case>
  <default name='Approved' >
    <assign name='Approved' property="response.IsApproved" value="1"/>
    <assign name='InterestRate'
            property="response.InterestRate"
            value="context.PrimeRate+10+(99*(1-(context.CreditRating/100)))">
      <annotation>
        Copy InterestRate into response object.
      </annotation>
    </assign>
  </default>
</switch>
FeedbackOpens in a new tab