发表于:2002-05-20 23:54:00
9楼
I can write in English only because my Chinese platform crashed. For your reference following is a example of function with parameters and how to call this function and pass parameter values from another function.
//Function with input and output parameters
FUNCTION FC 1 : VOID
TITLE = Test sample 1
VAR_INPUT
xxx : INT;
END_VAR
VAR_OUTPUT
yyy : CHAR;
END_VAR;
VAR_IN_OUT
zzz : BOOL;
END_VAR;
BEGIN
NETWORK
......
END_FUNCTION
//Call a function with parameters
FUNCTION FC 2 : VOID
TITLE = Test sample 2
BEGIN
NETWORK
TITLE = Calling a function with parameters
CALL FC 1 (
xxx := 123,
yyy := a_char_variable,
zzz := a_bool_variable);
NOP 0;
NETWORK
........
END_FUNCTION
In STEP 7 it is simpler. If you can write LAD program, in Variable Declaration Table you just give the names and datetype of input and output variables. You can use these variables in this program(function). In another program to call this function you just insert a Program Elements-->FC blocks-->FC1. Then all function parameters are displayed. Be carefull, datatype of variables or values you pass to parameters must match with datatype of parameters.