martin3885
Member
Hi,
I try to work with ANY data type. I read in Step7's help about it, but there is no example how to use it. Yesterdy I found this thread. RolfB has placed there an example with ANY data type.
FUNCTION FC 15 : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
in_PDatabase : ANY ; // Sample P#DB15.dbx0 Byte 1
in_iBitoffset : INT ;
END_VAR
VAR_OUTPUT
out_Result : BOOL ;
END_VAR
VAR_TEMP
P : STRUCT
Kenn : BYTE ;
Typ : BYTE ;
lenght : WORD ;
DBnum : WORD ;
Bereich : DWORD ;
END_STRUCT ;
END_VAR
BEGIN
NETWORK
TITLE =Copy Pointer in local structure
L P##in_PDatabase; // Any-Pointer
LAR1 ;
L B [AR1,P#0.0]; // ID S7
T #P.Kenn;
L B [AR1,P#1.0]; // Data Typ
T #P.Typ;
L W [AR1,P#2.0]; // Lenght
T #P.lenght;
L W [AR1,P#4.0]; // DBno
T #P.DBnum;
L D [AR1,P#6.0]; // Area
T #P.Bereich;
AUF DB [#P.DBnum]; // open Datablock
//************************************************
//add Bitoffset to pointer
//************************************************
LAR1 #P.Bereich; // Area --> AR1
L #in_iBitoffset; // INT add Bit Offset
+AR1 ; // to -> ar1
U DBX [AR1,P#0.0]; // Sample ?=1
= #out_Result; // Test if function work
END_FUNCTION
Do I always need such a "P" structure?
What if I want to point to FB and not DB?
I would be thakfull if someone could show me another example with variable of ANY data type, thus I could compare them and see how does ANY data type works.
I try to work with ANY data type. I read in Step7's help about it, but there is no example how to use it. Yesterdy I found this thread. RolfB has placed there an example with ANY data type.
FUNCTION FC 15 : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
in_PDatabase : ANY ; // Sample P#DB15.dbx0 Byte 1
in_iBitoffset : INT ;
END_VAR
VAR_OUTPUT
out_Result : BOOL ;
END_VAR
VAR_TEMP
P : STRUCT
Kenn : BYTE ;
Typ : BYTE ;
lenght : WORD ;
DBnum : WORD ;
Bereich : DWORD ;
END_STRUCT ;
END_VAR
BEGIN
NETWORK
TITLE =Copy Pointer in local structure
L P##in_PDatabase; // Any-Pointer
LAR1 ;
L B [AR1,P#0.0]; // ID S7
T #P.Kenn;
L B [AR1,P#1.0]; // Data Typ
T #P.Typ;
L W [AR1,P#2.0]; // Lenght
T #P.lenght;
L W [AR1,P#4.0]; // DBno
T #P.DBnum;
L D [AR1,P#6.0]; // Area
T #P.Bereich;
AUF DB [#P.DBnum]; // open Datablock
//************************************************
//add Bitoffset to pointer
//************************************************
LAR1 #P.Bereich; // Area --> AR1
L #in_iBitoffset; // INT add Bit Offset
+AR1 ; // to -> ar1
U DBX [AR1,P#0.0]; // Sample ?=1
= #out_Result; // Test if function work
END_FUNCTION
Do I always need such a "P" structure?
What if I want to point to FB and not DB?
I would be thakfull if someone could show me another example with variable of ANY data type, thus I could compare them and see how does ANY data type works.