Sample Macro Code - KEP MMI-1500 Installation & Operation Manual

Mmi-touchscreen series
Table of Contents

Advertisement

14.7 Sample Macro Code

1: Various expressions
(Arithmetic, Bitwise shift, Logic and Comparison)
Macro_Command main( )
int b[10]
b[0]= (400 + 400 << 2) / 401
b[1]= 22 *2 - 30 % 7
b[2]= 111 >> 2
b[3]= 403 > 9 + 3 >= 9 + 3 < 4 + 3 <= 8
b[4]= Not 8 + 1 And 2 + 1 Or 0 + 1 Xor 2
b[5]= 405 And 3 And Not 0
b[6]= 8 & 4 + 4 & 4 + 8 | 4 + 8 ^ 4
b[7]= 6 - ~ 4
b[8]= 0x11
b[9]= 409
End Macro_Command
2: For-Next
Macro_Command main( )
int a[10]
int b[10]
int i For i = 0 To 4 Step 1
If( a[0] == 400 ) Then
GetData(a[0] ,4x_Bin ,1,9)
SetData(b[0] ,4x_Bin ,11,10)
End If
Next
End Macro_Command
3: While-Wend, if, break, continue
Macro_Command main( )
int b[10]
int I
b[0]= (400 + 400 << 2) - 401 + 99
b[1]= 100
i = 5
While i == 5
SetData(b[1] ,4x_Bin ,11,1)
If b[1] == 100 Then
Break
SetData(b[0] ,4x_Bin ,12,1)
i = 4
Continue
SetData(b[0] ,4x_Bin ,13,1)
End If
Wend
End Macro_Command
5: Initializing and working with arrays and PLC data
4: Global variables and function call
char g
Sub int sin(int j ,int k)
int y
SetData(j ,4x_Bin ,14,1)
GetData(y ,4x_Bin ,15,1)
g = y
Return y
End Sub
Macro_Command main( )
int b[5]
int i
b[0]= (400 + 400 << 2) - 401 + 99
b[1]= 100
b[2]= 111
b[3]= 403
i = 5
While i == 5 - 20 % 3
SetData(b[1] ,4x_Bin ,11,1)
If b[1] == 100 Then
SetData(b[0] ,4x_Bin ,12,1)
i = sin(b[2],b[3] )
SetData(g ,4x_Bin ,17,1)
SetData(i ,4x_Bin ,16,1)
End If
Wend
End Macro_Command
Macro_Command main( )
192

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mmi-750Mmi-730Mmi-850

Table of Contents