MDE スクリプトのヒント: 可変数のタグを数式に取り込み、それに基づいて入力値を持つ
  • 29 Aug 2025
  • PDF

MDE スクリプトのヒント: 可変数のタグを数式に取り込み、それに基づいて入力値を持つ

  • PDF

記事の要約

通常、MDE スクリプトは、Cell 関数で呼び出されるすべての入力タグに入力値がある場合にのみ起動します。ただし、次のようなスクリプトを記述することで、可変数の入力セルを考慮に入れるスクリプトを作成できます。

結果は次のようになります。

スクリプトの全文:

'Code:
Dim sum As Double
Dim cnt As Double
Dim avg As Double

If Cell("Plantname.MDE.BW_R").HasValue Then
    cnt += 1
    sum += Cell("Plantname.MDE.BW_R").Value
End If

If Cell("Plantname.MDE.BW_M").HasValue Then
    cnt += 1
    sum += Cell("Plantname.MDE.BW_M").Value
End If

If Cell("Plantname.MDE.BW_L").HasValue Then
    cnt += 1
    sum += Cell("Plantname.MDE.BW_L").Value
End If

If cnt > 0 Then
    OV = sum / cnt
Else
    OV = Nothing
    ClearTagCellValue(C.DataUTag)
End If

この記事は役に立ちましたか?