trimRight
Short summary
This method is used to remove the whitespace from the end of the string. It does not really remove it, it just decreases the string length.
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringAddress | POINTER TO BYTE | start address of the string | input |
| stringLength | UDINT | length of the string stringAddress | inout |
| trimString | BOOL | TRUE means remove the whitespace, FALSE means do not remove the whitespace | input |
Code
Declaration
METHOD PROTECTED trimRight
VAR_INPUT
(* start address of the string *)
stringAddress :POINTER TO BYTE;
END_VAR
VAR_IN_OUT
(* length of the string ``stringAddress`` *)
stringLength :UDINT;
END_VAR
VAR_INPUT
(* ``TRUE`` means remove the whitespace, ``FALSE`` means do not remove the whitespace *)
trimString :BOOL;
END_VAR
VAR
(* index of the current character *)
character :LINT;
END_VAR
Implementation
RETURN(NOT trimString OR_ELSE stringAddress = 0 OR_ELSE stringLength <= 0);
character := stringLength;
WHILE(character >=0) DO
RETURN (NOT THIS^.isCharWhiteSpace(stringAddress[character := character-1]));
stringLength := stringLength-1;
END_WHILE