ParmToBuff
| Description: | Returns a buffer of formatted numeric parameter values. |
| Returns: | Buffer |
Usage: ![]() |
Script Only. |
| Function Groups: | Advanced Module, String and Buffer |
| Related to: | ArrayToBuff | BuffToArray | BuffToParm |
Format: ![]() |
ParmToBuff(Object, Index, N, Option, Size, Skip [, BadData]) |
| Parameters: |
| Object | ||||||||||||||||||||||||
| Required. Any object (the object value of any running module instance). | ||||||||||||||||||||||||
| Index | ||||||||||||||||||||||||
| Required. Any numeric expression giving the first parameter to format, starting from 1. | ||||||||||||||||||||||||
| N | ||||||||||||||||||||||||
| Required. Any numeric expression giving the number of parameters to format. If there are fewer actual parameters than N + Index, this statement stops at the last parameter. | ||||||||||||||||||||||||
| Option | ||||||||||||||||||||||||
Required. Any numeric expression which specifies the format of the buffer read.
|
| Size | |||||||||||||||
Required. Any numeric expression giving the number of digits in each datum. It has a different meaning for each option as indicated:
For Options 7 and 9 the data is written as appropriate binary format. |
| Skip | ||||||||
| Required. 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. | ||||||||
| BadData | ||||||||
An optional parameter that designates how invalid data is to be handled, according to the following table: Defaults to 0 if missing or invalid.
|
| Comments: | This function may only be used with parameters containing numeric data. It is useful for encoding serial port data when writing I/O drivers. |
Example:
If a module call looks like:
Write(1, 2, 3, x, y, z);
And there is a statement in module Write that looks like:
If ! Valid(writePacket);
[
writePacket = ParmToBuff(Self(){ Current module },
4 { Skip first 3 parameters },
NParm(Self()) - 3
{ Use rest of parameters },
0 { Unsigned binary format },
16 { Bits },
0 { No skip });
]
Because this statement encodes x, y, and z as 16 bit unsigned integers, the returned buffer will be 16 bytes long, byte-ordered as follows:
|
Byte |
Description |
|---|---|
|
0 |
Low byte of x |
|
1 |
High byte of x |
|
2 |
Low byte of y |
|
3 |
High byte of y |
|
4 |
Low byte of z |
|
5 |
High byte of z |
