Skip to main content

isContainsNoCheckNecessary

Short summary

Methods for checking if an assert statement with contains or contains not, makes sense based on the string lengths

= :return: FLASE means it's not necessary to check the string content, TRUE means it's necessary to check the string content to know if the assertion is true or false

  • Return type: BOOL

Parameters

NameTypeCommentKind
stringToCheckPOINTER TO BYTEcurrent string to checkinput
searchStringPOINTER TO BYTEstring must be found in stringToCheckinput
lengthStringToCheckUDINTlength of current string to checkinput
lengthSearchStringUDINTlength of searchStringinput
additionalTextTc2_System.T_MaxStringjust additional text if assert is falseinput
messageAssertMessagemessage if the assertion is falseinput

Code

Declaration

METHOD PROTECTED isContainsNoCheckNecessary :BOOL
VAR_INPUT
(* current string to check *)
stringToCheck :POINTER TO BYTE;
(* string must be found in ``stringToCheck`` *)
searchString :POINTER TO BYTE;
(* length of current string to check *)
lengthStringToCheck :UDINT;
(* length of ``searchString`` *)
lengthSearchString :UDINT;
(* just additional text if assert is false *)
additionalText :Tc2_System.T_MaxString;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR

Implementation

isContainsNoCheckNecessary := FALSE;
IF ((
lengthSearchString > lengthStringToCheck
) OR_ELSE (
(stringToCheck = 0) XOR (searchString = 0)
)
) THEN
RETURN; //assert is true
ELSIF ((
(stringToCheck = 0) AND_THEN (searchString = 0)
) OR_ELSE (
lengthSearchString = 0
)
) THEN
THIS^.assertionWasWrong(message, additionalText);
RETURN;
END_IF
isContainsNoCheckNecessary := TRUE;