Technical data
Linkage with PLC
CP 486 ⋅ 00/14 VIPA GmbH 161
6.4.3.5 Write a Block into the PC
FUNCTION CP_writen_AG(size, typ, bst : BYTE; adr : longint; len : word;
p : POINTER) : integer;
size: data size of block elements (see Tab.4)
typ: data type block elements (see Tab. 3)
bst: module number
adr: address in module or absolute address
len: number or data in words
p: pointer to the data block to be written
Return: job number or negative number if there was an error
This function calls the driver function "write a block into the PC". The registers are preset according
to the transferred parameters when calling up. Meaning of the parameters is described in the section
of driver function. If the driver has detected an error during the execution, then the respective error
message (negative number) is returned as function value. If the function can be executed without
errors, the job number $80 (hex) is returned as function value.
Recommended calling method
VAR a_nr, (* job number for read job*)
stat : INTEGER; (* momentaneous job status *)
i : INTEGER;
buff : ARRAY[1..100 ] OF BYTE; (* data to be written *)
BEGIN
...
FORi:=1TO100DO
buff[i] := i; (* preset data buffer *)
(* start job *)
a_nr := CP_writen_AG(B_BLOCK, DB_BLK, 5, 10, 100, Addr(buff));
IF a_nr < 0 (* error occurred *)
THEN WriteLn('job finished with error: ', a_nr);
ELSE BEGIN (* a_nr contains job number *)
REPEAT
stat := CP_stat_AG(a_nr, NIL); (* read job status *)
UNTIL stat <> REQ_WRKN; (* as long as job is ready with or without errors *)
CASE stat OF
REQ_NO_ERR: WriteLn('buffer was written');
REQ_UNDEF: WriteLn('job status nondefined.');
ELSE WriteLn('job is ready with error: ', stat);
END;
END;