bara_hence
Member
Ok have read some of the old threads but this subject still confuses me..
What i want to do is:
I have a FB wich i would like to pass what to send and what to recieve to I would like to be able to pass it either as a constant (P#DB666.DBX66.6 BYTE 66) or as a ANY variable wich I have build in the calling FC or FB..
In the FB i would like to pass the pointer on to a send FB.
According to this post http://www.plctalk.net/qanda/showpost.php?p=169469&postcount=8
I have to do like this:
Then the confusion starts.. could I now call the other FB using the struct AnyPointer as an input? The other FB is BSEND so I cannot alter this..
What i want to do is:
I have a FB wich i would like to pass what to send and what to recieve to I would like to be able to pass it either as a constant (P#DB666.DBX66.6 BYTE 66) or as a ANY variable wich I have build in the calling FC or FB..
In the FB i would like to pass the pointer on to a send FB.
According to this post http://www.plctalk.net/qanda/showpost.php?p=169469&postcount=8
I have to do like this:
Code:
FUNCTION_BLOCK FB 316
TITLE =
VERSION : 0.1
VAR_INPUT
pAny : ANY ;
END_VAR
VAR_TEMP
AnyPointer : STRUCT
wType : WORD ;
iQuantity : INT ;
iDBNumber : INT ;
dwAreaPointer : DWORD ;
END_STRUCT ;
dwSavedAr2 : DWORD ;
bCallFC316 : BOOL ;
END_VAR
BEGIN
NETWORK
TITLE =passing on an any pointer (FB)
TAR2 #dwSavedAr2; //save current value of AR2
L P##pAny; //pointer to parameter in instance
AD DW#16#7FFFF; //mask off area
TAR2 ; //get current instance
+D ; //add parameter offset
LAR2 ; //for indirect address
CDB ; //global DB instance DB swap
//****
//no stat or parameter access allowed
//****
L W [AR2,P#0.0];
T #AnyPointer.wType;
L W [AR2,P#2.0];
T #AnyPointer.iQuantity;
L W [AR2,P#4.0];
T #AnyPointer.iDBNumber;
L D [AR2,P#6.0];
T #AnyPointer.dwAreaPointer;
CDB ; //DB's back to how they were
LAR2 #dwSavedAr2; //ar2 back to how it was
Then the confusion starts.. could I now call the other FB using the struct AnyPointer as an input? The other FB is BSEND so I cannot alter this..