PCD instruction wich allows to copy a text in to a other text.

FAQ #100886

The PCDs now support copying texts into other texts. The formats (@,$,...) are supported in the source text as well, which allows to enter the content of register directly into a text.


List of the minimal FW which is needed to support the copy text to text functionality:

PCD typeMinimum
FW version

 Instruction CopyText: 

CSF    Library; S.APPLICATION.Library
 Function                       ; S.APPLICATION.CopyText
 Source                          ; X/K 0…7999 | R 0...4095/16383*2
 Destination                   ; X/DB/K 0…7999 | R 0...4095/16383*2
 Count                            ; R 0…4095/16383*2   | K 0 | 0
 ErrorCode                     ; R 0…4095/16383*2   | K 0 | 0

*2 16383 Register are only available on NT-Systems (PCD2.M4.., PCD2.M5.., PCD3.)
                other PCD’s have maximal 4095 registers. 

Description of the parameter of the instruction CopyText: 

Source                          number of TEXT
It’s possible that this text contains formats (@,$,… )
Destination                   number of DB or number of TEXT
Count                            number of bytes have been copied into the destination buffer
if K 0 or 0 no reporting
ErrorCode                     error code
if K 0 or 0 no reporting

Description of the function CopyText: 
CopyText starts with rewriting of the whole destination text string with spaces (0x20).
If the Destination is too short, not the whole text is copied, but as many characters as possible. 
The count register contains the number of copied characters.
If the source length is smaller or equal to the destination length the number of copied character is equal to the source length, all character are copied, and no error indication and the error flag is set.

If the source length exceeds the destination length the number of copied character is equal to the destination length, not all character are copied, and error code 12 with error flag is set. 

The Error Flag of the PCD is set if any error occurs ( for example "Destination too short", "Destination not writable", "Source is a DB", "Wrong Parameters", "Text or DB doesn't exist", "Source = Destination", ... )

List with the error values for the ErrorCode

0no error
1Fatal error, failure in media definitions (wrong media)
2The count parameter  is a constant with a value different from 0
3Source or destination is neither text nor db
4Source text doesn't exist
5Destination text doesn't exist
6Destination = Source
7Source is DB
8Destination is not writable
9Forbidden first character ( 0xFD, 0xFE, 0xFF ) in destination text at text number < 4000.
10Forbidden character in destination text  at text number < 4000.
11  Error while copying text
12Not whole text copied ( destination too short )
13The count parameter is neither a register nor a constant

The CSF exists with error on wrong media type of the ErrorCode Parmater, and on all indicated errors. 

Note :
The Destination text/db must be writable ( RAM resident ) and the user has to include the ApplicationLib.inc before using this csf. 

Source text:
Text 100 “Alarm on station 10, @L0100. Motor is to hot. Temperature is $R0110°C.
Please call $L0020”

Register 100 has the value 2
Register 0110 has the value 220
Text 2 “Section B”
Text 20 “John at the number 044 345 32 32” 

The Register 100 contains the pointer to the sub-text.
If the Register 100 has the value 2 then the text 2 is inserted on the position @L0100. 
After copying the source text to the destination text, the destination text will be the following:
“Alarm on station 10, Section B. Motor is to hot. Temperature is 220°C. Please call John at the number 044 345 32 32” 

The PG5 Example can be downloaded from this FAQ.



Local FAQ Deutschland / SEdit (IL programming)

PG5 2.0 / Mode-C

Last update: 21.05.2015 13:10

First release: 21.02.2008 14:25

Views: 7982

The requested software / document is no longer marketed by Saia-Burgess Controls AG and without technical support. It is an older software version which can be operated only on certain now no longer commercially available products.