Defining Variables
  • 30 Jan 2024
  • PDF

Defining Variables

  • PDF

The content is currently unavailable in Ja - 日本語. You are viewing the default English version.
記事の要約

Dim

Variable names that are used in calculations must be defined.  For normal calculations, the variables are defined as:

                Dim NewValue as Single

The variable name is “NewValue”.   Example code is:

Dim NewValue as single

‘Sum Input tags 3, 5 and 9 and place in Output tag 4

 NewValue =  GD(3) + GD(4) + GD(9)

Tag(4, NewValue)

Static

Variable names that are used for doing calculations must be defined.  Normally they are defined with the Dim statement.  Each time the routine is executed, the number is zeroed.  To keep the value between iterations, define the variable using Static as follows:

                Static OldValue as Single

The variable name is “OldValue”.   Example code is:

 Dim NewValue as single

Static OldValue as single

‘Sum Input tags 3, 5 and 9 and place in Output tag 4

NewValue =  GD(3) + GD(4) + GD(9)

If OldValue <> NewValue then

Tag(4, NewValue)

End If

OldValue = NewValue


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

What's Next