bmw_apprentice
Member
Hi All,
It has been a long, long time. But in times of crisis this is somewhere I hold in the highest regard for accurate and swift responses.
I have searched but I am struggling to find an answer.
I am working on a program to sequence some data, I want to seperate up some strings I have built up in local data and put them into a DB one character at a time ready for processing. I thought about using the MID function to individually split up every char in the string but this seemed a little clunky to do 400 times.
So I thought about using a blockmov for the strings but skipping the first 2 bytes of header into the array of chars. This means that I can just get the LEN of the string and do it once per string (about 40) in a loop of all the data.
However I have hit a knowledge wall.
I am using SCL for the first time in anger and it is a learning curve. Programming in Step 7 rather than TIA also means none of the nice stuff. So perhaps this is easy, perhaps not.
I have built up all my strings in my local FB and they are ready to transport with the BLKMOV, however how to I address a pointer to the local FB variables? Essentially to the iDB. I need to be able to strip off the first 2 bytes of the string by dynamically addressing the source pointer for the BLKMOV. I understand how to construct pointers but when it comes to iDB/local variables is there any way to address them rather than symbolically so as to strip off the header data?
Declared the pointer here:
This is the code, in essence, that will address the pointer. My issue is the section in bold. For a "regular" DB or data I can just calculate it. What about for the iDB of this FB instance?
I understand that I can address local variables to a block move, but what about if I want to change that source data? Essentially outside of it's data type.
I hope this makes sense...
It has been a long, long time. But in times of crisis this is somewhere I hold in the highest regard for accurate and swift responses.
I have searched but I am struggling to find an answer.
I am working on a program to sequence some data, I want to seperate up some strings I have built up in local data and put them into a DB one character at a time ready for processing. I thought about using the MID function to individually split up every char in the string but this seemed a little clunky to do 400 times.
So I thought about using a blockmov for the strings but skipping the first 2 bytes of header into the array of chars. This means that I can just get the LEN of the string and do it once per string (about 40) in a loop of all the data.
However I have hit a knowledge wall.
I am using SCL for the first time in anger and it is a learning curve. Programming in Step 7 rather than TIA also means none of the nice stuff. So perhaps this is easy, perhaps not.
I have built up all my strings in my local FB and they are ready to transport with the BLKMOV, however how to I address a pointer to the local FB variables? Essentially to the iDB. I need to be able to strip off the first 2 bytes of the string by dynamically addressing the source pointer for the BLKMOV. I understand how to construct pointers but when it comes to iDB/local variables is there any way to address them rather than symbolically so as to strip off the header data?
Declared the pointer here:
Code:
pDST, : ANY; // DB address ANY pointer - used for accessing DB data
pAnyDST AT pDST :
STRUCT // Diassembled ANY pointer structure
bS7Code : BYTE; // Code for S7 (fixed at 16#10)
bDataType : BYTE; // Code for data type
iLength : INT; // Repetition factor = Send/receive length
iDBNumber : INT; // Data block Number
bMemoryArea : BYTE; // Specified memory area
bByteAddressMSB : BYTE; // Byte address most significant bits
wByteAddressLSB : WORD; // Byte address least significant bits
END_STRUCT;
This is the code, in essence, that will address the pointer. My issue is the section in bold. For a "regular" DB or data I can just calculate it. What about for the iDB of this FB instance?
Code:
(*Contruct the pointers for the move destination*)
pAnyDT.bS7Code := 16#10;
pAnyDT.bDataType := 16#02;
pAnyDT.iLength := 8;
pAnyDT.iDBNumber := iGlobalDBNumber;
pAnyDT.bMemoryArea := 16#84;
pAnyDT.bByteAddressMSB := 0;
pAnyDT.wByteAddressLSB := INT_TO_WORD(CManagementDataLength*8);
I understand that I can address local variables to a block move, but what about if I want to change that source data? Essentially outside of it's data type.
Code:
iDateTime:=BLKMOV(srcblk:= dtSFC1DateTime, dstblk:= pDT);
I hope this makes sense...