The Trim function returns the given string S with all leading and trailing spaces removed.

Declaration: function Trim(const S: string): string;

An easy example follows.

procedure OnMapEvent(var Value:Variant);
var aString : string;
begin
//Returns 'This is text with spaces at each end.'
aString := Trim(' This is text with spaces at each end. ');
//Returns and writes 'This is text with spaces at each end.ZZZZ' to the log
LogInfo(aString+'ZZZZ');
end;