FUNCTION FC200 : VOID
TITLE =transfer bytes between db's
//Transfer bytes of data between data blocks using SFC20
//
VAR_INPUT
dbSourceDB : BLOCK_DB ; //source data block
iSourceDBNumber : INT ; //source data block number (set to zero to use above)
iSourceByteOffset : INT ; //source data byte offset
dbDestinationDB : BLOCK_DB ; //destination data block
iDestinationDBNumber : INT ; //destination data block number (set to zero to use above)
iDestinationByteOffset : INT ; //destination data byte offset
iNumberOfBytes : INT ; //number of bytes to xfer
END_VAR
VAR_OUTPUT
iMoveResult : INT ; //result from block xfer SFC20
END_VAR
VAR_TEMP
pSourceDB : ANY ;
pDestDB : ANY ;
END_VAR
BEGIN
NETWORK
TITLE =any pointer for source
LAR1 P##pSourceDB;
L W#16#1002; //specify ANY pointer, type 02 = BYTE
T W [AR1,P#0.0];
L #iNumberOfBytes; //number of bytes to transfer
T W [AR1,P#2.0];
L 0;
L #iSourceDBNumber; //if iSourceDBNumber = 0 then
==I ; // opn db and use DBNO to find number
JC opnS; // else use iSourceDBNumber
JU trnS;
opnS: OPN #dbSourceDB;
L DBNO; //data block to use
trnS: T W [AR1,P#4.0];
L DW#16#84000000; //global data block for area pointer
L #iSourceByteOffset;
SLD 3;
+D ;
T D [AR1,P#6.0]; //start of data block
NETWORK
TITLE =any pointer for destination
LAR1 P##pDestDB;
L W#16#1002; //specify ANY pointer, type 02 = BYTE
T W [AR1,P#0.0];
L #iNumberOfBytes; //number of bytes to transfer
T W [AR1,P#2.0];
L 0;
L #iDestinationDBNumber; //if iDestinationDBNumber = 0 then
==I ; // opn db and use DBNO to find number
JC opnD; // else use iDestinationDBNumber
JU trnD;
opnD: OPN #dbDestinationDB;
L DBNO; //data block to use
trnD: T W [AR1,P#4.0];
L DW#16#84000000; //global data block for area pointer
L #iDestinationByteOffset;
SLD 3;
+D ;
T D [AR1,P#6.0]; //start of data block
NETWORK
TITLE =copy data
CALL "BLKMOV" (
SRCBLK := #pSourceDB,
RET_VAL := #iMoveResult,
DSTBLK := #pDestDB);
NOP 0;
NETWORK
TITLE =Make sure the ENO shows the BLKMOV result
A BR; // BR is 1 for no error
JC ok;
JU nok;
ok: SET ; // Make the ENO high
SAVE ;
JU end;
nok: CLR ; // Make the ENO low
SAVE ;
end: NOP 0;
END_FUNCTION