Greetings fellow code monkeys!
What I am trying to do is: Getting the total length of contents in a db. (not di)
I thought linking a db to the ANY input would work. Alas it didn't.
Don't mind the udt code, that works.
If anyone has got any ideas, please tell me.
Thanks in advance!
What I am trying to do is: Getting the total length of contents in a db. (not di)
Code:
FUNCTION_BLOCK FB102
VAR_INPUT
dbObjData:ANY;
END_VAR
VAR_OUTPUT
udtlen:INT;
dblen:INT;
END_VAR
VAR_TEMP
taD : ANY;
tstD AT taD : STRUCT
S7Code : BYTE; // Code for S7
DataType : BYTE; // Code for data type
Length : WORD; // Repetition factor = Send/receive length
DBNumber : WORD; // Data block Number
Bit_Pointer: DWORD; // Byte address
END_STRUCT;
tUDT:UDT101;
tUDTlength:INT;
tDbLength:INT;
END_VAR
VAR
END_VAR
//Getting UDT lenght
taD:=tUDT;
tUDTLength:=WORD_TO_INT(tstD.Length);
//Getting DB length
taD:=dbObjData;
tDbLength:=WORD_TO_INT(tstD.Length);
udtlen:=tudtlength;
dblen:=tDbLength;
END_FUNCTION_BLOCK
Don't mind the udt code, that works.
If anyone has got any ideas, please tell me.
Thanks in advance!