This version introduces two new variables which are made available to your script. When 232key Pro receives data from the connected device, it tries to match a regular expression. The string matched by the first capturing group is stored in a variable named value.
The following additional variables were introduced in this version:
- valueDouble: contains the value string converted to a Double or null if no conversion was possible.
- valueDecimal: contains the value string converted to a Decimal or null if no conversion was possible.
Data received from the scale:
S S 5.000 kg<13><10>
Captured in value string:
Script to output the weight only if it is greater than 0.1 kg:
if (valueDecimal>0.1m) return valueDecimal.ToString();
Output (note: valueDecimal preserves any trailing zeros, valueDouble does not):