Pascal style strings via DDE
(SP##) indicates a special specifier used only with the Allen-Bradley Integer (N) or ASCII (A) PLC data types for Pascal style strings.
Strings stored in this manner have the length of the string indicated by a length byte in the first byte of the string (High Byte of the first register).
The 'S' indicates string, the 'P' indicates Pascal style and the ## indicates the length of the string in elements. Data is read up to the requested length of the string or to the length of the string that is specified in the high byte of the first register whichever comes first.
You may specify multiple strings with the length (block size) specifier (L##). However, the maximum combination of individual string lengths and the block size must not exceed the maximum size of a packet. For Allen-Bradley this maximum packet size is 100 elements, with the exception of the Allen-Bradley Ethernet driver where the maximum is 1000 elements.
Example:
A single string request with a length of 10 elements would be 20 bytes (2 bytes/element). The item for Allen-Bradley would be: N7:0,L1,C1,SP10. The string is Pascal style and would appear as PSAMPLE
in the data table.Register (Element) | High byte (Hex) | Low byte (Hex) | High byte (ASCII) | Low byte (ASCII) |
---|---|---|---|---|
N7:0 | 7 | 80 | P | |
N7:1 | 83 | 65 | S | A |
N7:2 | 77 | 80 | M | P |
N7:3 | 76 | 69 | L | E |
N7:4 | x | x | ||
N7:5 | x | x | ||
N7:6 | x | x | ||
N7:7 | x | x | ||
N7:8 | x | x | ||
N7:9 | x | x |
The high byte of register N7:0 of the string contains the length of the string in bytes, 7 Hex (7 decimal). Please note that even though the requested length is 10 elements (20 bytes), only 7 bytes are returned as that is the length specified in the high byte of N7:0.
Provide Feedback