ページの先頭行へ戻る
Symfoware Server V12.7.0 WebDBtoolsユーザーズガイド
FUJITSU Software

6.2.3 <!FOREACH>

説明

<!FOREACH>は、リスト内の要素を順次取り出し、その要素の値をnameで指定された変数に設定するタグです。

構文

<!FOREACH collection name [ LABEL=label ] > ~ <!/FOREACH>

パラメタ

collection

name

label

使用例

<!SETVAR LIST '(1, 2, 3)'>
<!FOREACH LIST L>
  <TT>value = <!HREPLACE 'L'></TT><BR>
<!/FOREACH>
      ↓
  value = 1
  value = 2
  value = 3

注意

同一のデータに対する<!FOREACH>は、同時に1つしか実行できません。
同一のデータに対して、複数の<!FOREACH>を実行した場合の結果は、保証されません。

<!FOREACH collection t>
  <!FOREACH collection s> → 誤り。同一のデータcollectionに
                              対する2つ目の<!FOREACH>
    <!IF 't eq s'> ... <!/IF>
  <!/FOREACH>
<!/FOREACH>
<!SETVAR alias collection REF>
<!FOREACH collection t>
  <!FOREACH alias s> →  誤り。collectionとaliasは同一
                          データを指している
    <!IF 't eq s'> ... <!/IF>
  <!/FOREACH>
<!/FOREACH>
<!SETVAR copied collection>
<!FOREACH collection t>
  <!FOREACH copied s> → OK。copiedはcollectionと同じ
                          内容だが、コピーされた別のデータ
    <!IF 't eq s'> ... <!/IF>
  <!/FOREACH>
<!/FOREACH>