Update cookies preferences
Promotic

SetStringFix - method of the PmBuffer object

Description:
Writing the text string of fixed length.
Syntax:
Empty SetStringFix(Long nOffset, String sValue, Long nLength, [Long nPad], [Long nEncoding])
Parameters:
nOffset(Long) Specifies the position of written value in the data block.
The whole written value must 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.
>= 0 - Index (in bytes, zero-based index) in the data block.
-2 - The whole item is added to the end of the data block. The size of the data block is increased by the written item.
-4 - The internal automatic position is used (see the AutoOffset property). It points behind the last read or written value.
This operation shifts the internal automatic position behind the read/written value.
If the items are read/written one by one then it is not necessary to define the position manually, but it is better to use this automated positioning.
sValue(String) Text string being written.
nLength(Long) Fixed size in bytes of reserved space in the data block for the text string.
The text string is not terminated by the NULL character, but if its current length is less than the defined fixed length then it is filled from the right by defined character nPad (usually NULL or space) up to the defined fixed length.
nPad[optional] (Long) The value of the character that will be used for folling up the text string from the right to the defined fixed length.
The 0 value (default) is the NULL character.
The 32 value is the space character.
nEncoding[optional] (Long) Encoding of a text 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 1250).
1 - (UTF-8) Each character is stored in 1, 2 or 4 bytes, it means has variable length. The advantage is that the latin characters (ASCII) are stored in a single byte. Only special characters and characters with diacritics (i.e. national dependent characters) 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 length. The advantage is that most characters are stored in 2 bytes so these strings are easy to work with (because of the fixed length).
This encoding is used internally in Windows OS, but also in the JavaScript language or .NET, because the mannipulation with these fixed strings is easier.
3 - (UTF-16 BE) (Big Endian) Each character is stored in 2 bytes (or exceptionally in 4 bytes), i.e. it has a fixed length. The advantage is that most characters are stored in 2 bytes so these strings are easy to work with (because of the fixed length).
This encoding is used internally in Windows OS, but also in the JavaScript language or .NET, because the mannipulation with these fixed strings is easier.
CodePage - Each character is stored in one or more bytes according to the specified code page (CodePage). A code page is specified by its number, which is valid across all operating systems and programs. For example 1250 for Windows 1250 or 852 for Latin 2.
Note:
This method is also functional in Web panels.
Limitations for Web panels:
nEcoding=0 (ANSI) - encoding is not functional for characters with a value greater than 127
nEcoding=1 (UTF-8) - encoding is not functional in Internet Explorer
nEcoding=3 (UTF-16 BE) - encoding is not functional
nEcoding=CodePage - encoding is not functional
See also:
Example:
JavaScriptSelect and copy to clipboard

var oBuf = Pm.CreatePmBuffer();
var s1 = "Help me!";
oBuf.SetStringFix(-2, s1, 8, 0, 1);

History:
Pm9.00.30: New option 3 - (UTF-16 BE) in the nEncoding parameter.
Pm9.00.04: Created
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.