lengthIsBetween
Short summary
This assertion method checks if the current string stringToCheck length is between minLength and maxLength.
Processed strings must be in Windows-1252 or Windows-1251 encoding
Attention: All strings are handled as null-terminated byte streams
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringToCheck | POINTER TO BYTE | current string to check | input |
| minLength | UDINT | lower limit of the string length | input |
| maxLength | UDINT | upper limit of the string length | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
METHOD lengthIsBetween
VAR_INPUT
(* current string to check *)
stringToCheck :POINTER TO BYTE;
(* lower limit of the string length *)
minLength :UDINT;
(* upper limit of the string length *)
maxLength :UDINT;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
VAR
(* length of ``stringToCheck`` *)
lengthStringToCheck :UDINT;
END_VAR
Implementation
IF minLength > maxLength THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('lengthIsBetween'));
RETURN;
END_IF
lengthStringToCheck := THIS^.getStringLength(stringToCheck);
IF lengthStringToCheck < minLength OR_ELSE lengthStringToCheck > maxLength THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('lengthIsBetween'));
END_IF;