Skip to main content

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

NameTypeCommentKind
stringToCheckPOINTER TO BYTEcurrent string to checkinput
minLengthUDINTlower limit of the string lengthinput
maxLengthUDINTupper limit of the string lengthinput
messageAssertMessagemessage if the assertion is falseinput

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;