SetStringFix - method of object PmBuffer

Writing the character string with fixed lenght.
Empty SetStringFix(Long nOffset, String sValue, Long nLength, [Long nPad], [Long nEncoding])
Value = PmBuffer.SetStringFix(nOffset, sValue, nLength, nPad, nEncoding)
nOffset(Long) Defines the position of written value in the data block. The whole written item muyst be inside the data block, or the whole item is added to the end of the data block. The item is written either whole or not read at all.
The value -4 means that the internal automatic position is used (see AutoOffset). It points behind the last read or written value and increases continually. If the items are read/written one by one then it is not necessary to define the position, but it is handy to use this automated positioning.
The value -2 means that the whole item is added to the end of the data block. The size of the data bloc is then increased by the written item.
sValue(String) String being written.
nLength(Long) Fixed size of reserved space in the data block for the string in bytes. The string is not terminated by the NULL character, but if its current lenght is smaller than the defined fixed lenght then it is usually filled by defined character nPad (usually NULL or space) up to the defined fixed lenght.
nPad[optional] (Long) Definition of the character that will be used for folling up the string from right to the defined fixed lenght. The value 0 (default) is the NULL character. The value 32 is the space character.
nEncoding[optional] (Long) Encoding of character string in the data block.
0 (default) - (ANSI) Each character is stored in a single byte. The values from 0 to 127 represent an ASCII character table that is not changing in meaning. The values from 128 to 255 have different meaning in various localizations (code pages, e.g. Windows CP-1250).
1 - (UTF-8) Each character is stored in 1, 2 or 4 bytes, i.e has variable lenght. The advantage is that the latin characters (ASCII) are stored in a single byte. Only special characters and characters with diacritics are stored in multiple bytes. This storage is therefore very efficient. This encoding is commonly used for data exchange, data persistence and on the web.
2 - (UTF-16) Each character is stored in 2 bytes (or exceptionally in 4 bytes), i.e. it has a fixed lenght. The advantage is that most characters are stored in 2 bytes so these strings are easy to work with (because of the fixed lenght). This encoding is used internally in Windows, but also in JavaScript or .NET, because the mannipulation with these fixed strings is easier.
This method is also functional for Web panels. For InternetExplorer, the UTF-8 encoding does not work.

Pm9.00.04: Created
PROMOTIC 9.0.4 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice