Function Calls And Passing Parameters; Reading & Writing External Registers In A Macro - Maple Systems Silver Series Installation And Operation Manual

Operator interface terminal
Hide thumbs Also See for Silver Series:
Table of Contents

Advertisement

286
break
Used in looping control or select statement. It skips immediately to the end of the statement.
continue
Used in looping control statement. It quits the current iteration of a loop and starts the next one.
return
Returns to the function or module that called the current function.
Format
While [Condition]
[Statements]
Wend
Boolean ex pres sions
The value of Boolean expression is zero means FALSE.
The value of Boolean expression is not zero means TRUE.

Function Calls and Passing Parameters

A sub-function must be defined before its execution and is therefore placed before the main() macro function. If
there is an entry attempt into a function before it is first defined in the macro program will create a compiler error
'Function not defined'.
The above example code defines a sub-function called SQR(). This sub-function allows one variable to be passed
into it. The function then takes the value passed to it, multiplies its value by itself and then stores the result back
into the same variable. The result is returned back to the calling function.
Reading & Writing External Registers in a Macro
A macro program can communicate with external PLC data registers and I/O. The function GetData() receives data
from a PLC in the device table (or the OIT's local LW and LB memory). The function SetData() sends data to the
PLC (or the OIT's local LW and LB memory).
The GetData() or the SetData() can be hand typed according to the format listed below, or the "PLC API" button
located at the bottom-left of the macro editor dialog box allows the user to generate the GetData() or SetData()
function code by selecting the appropriate responses within the PLC API dialog box. Be sure to declare all variables
before using the 'PLC API' option. To set up the following functions, place the cursor after the declarations, and
1010-1007W, Rev 06
Sub int SQR(int x)
number
x = x * x
return x
End Sub
Macro_Command main( ) // This main function calls the SQR()
function.
int I = 5
I = SQR(I)
// Write the result to a LW
End Macro_Command
Sil ver Se ries In stal la tion & Op er a tion Man ual
Examples
While b [0]
a[i]
= 20 + i + * 10
If a[i ]== 120 Then
c = 200
Break
End If
i = i + 1
Wend
//This is the sub-function that squares a

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Silver Series and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Hm15070thHm15100t

Table of Contents