PointerToBuff
Description: |
Returns a buffer containing the numeric data from the variables pointed at by each element of the array. |
Returns: |
Buffer |
Usage: |
Script or steady state. |
Function Groups: |
Array, String and Buffer |
Related to: |
BuffToArray | BuffToParm | BuffToPointer | GetByte | ParmToBuff | SetByte |
Format: |
PointerToBuff(ArrayStart, N, Option, Size, Skip) |
Parameters: |
|
ArrayStart |
Required. Any expression that specifies the starting array element. This array contains the pointers to the variables whose values will be written to a buffer. If processing a multidimensional array, the usual rules apply to decide which dimension should be used. |
N |
Required. Any numeric expression giving the number of array elements to convert starting at the element given by the first parameter. If N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed. |
Option |
Required. Any numeric expression that specifies the format of the buffer write:Option | Format |
---|
0 | Unsigned binary (low byte first) | 1 | Signed binary (low byte first) | 2 | BCD (binary coded decimal) (low byte first) | 3 | ASCII octal (high byte first) | 4 | ASCII decimal (high byte first) | 5 | ASCII hex (high byte first) | 6 | ASCII floating point (high byte first) | 7 | IEEE float/double (low byte first) | 8 | <obsolete> | 9 | Allen-Bradley® PLC/3 floating point | 10 | VAX single precision floating point |
For Options 7 and 9 the data is written as appropriate binary format. |
Size |
Any numeric expression giving the number of digits in each datum. Size has a different meaning for each option as indicated below:Option | Size Meaning | Size Range |
---|
Binary types | Number of bits | 1 - 32 bits | BCD | Number of 4-bit digits | 1 - 8 digits | ASCII types | Number of bytes | 1 - 32 bytes | Float types | Precision | 1 for single precision, 2 for double precision |
|
Skip |
Any numeric expression giving the number of buffer bits/digits/bytes to skip after writing each non-floating point element. For floating point types, this parameter must be set to 0. |
Comments: |
This function may only be used with pointers pointing at numeric data. Any invalid array elements, or invalid data pointed at by array elements are written to the buffer as formatted zeroes. This function is useful for writing I/O drivers and saving arrays of data in RAM with a fraction of the memory requirement. |
Example:
buff1 = PointerToBuff(dataPtr[0]{ Starting point in array },
100 { No. of elements to convert },
5 { Write as ASCII hex },
4 { Number of bytes per },
0 { No skip between writes });
This produces a formatted buffer 400 bytes long (100 four byte groups). Each 4 bytes is a hex number corresponding to a variable pointed at by an element in the array. Invalid array elements and invalid data are written as 0.
Trihedral and VTScada are registered trade marks of Trihedral Engineering Limited
© Trihedral Engineering Limited 1983- 2022 All rights reserved.