How to delete last char

A third option is this:

SetLength(Query,LENGTH(Query)-1)

Try this:

var
  query : String;
begin
  query:= 'test=1&line=5&';
  delete(query,length(query),1);

I think I would write this as:

NewValue := OldValue.Substring(0, OldValue.Length - 1);

I think the functional interface, that is a function returning a new value, is usually to be preferred over a procedure with side-effects. I find the assignment operator is a clear indicator that a new value is being assigned to the variable. Using a functional approach makes the syntax much cleaner when you want the new value to be stored in a different variable from the original value.

Tags:

Delphi