Display the longest word

Quite a long time ago, there was a task at the school Olympiad (just below), I couldn’t write it in pascal, but I easily finished it in php.
But it’s still interesting how the solution would look in pascale

Here is the task itself:

A simple declarative sentence is introduced (words are separated by a space). Display the longest word on the screen.
The program should: a)accept the original sentence from the keyboard b)display the word of the greatest length

Here is my php solution

$item = $_POST["item"];//   
$array = explode(" ",$item);  
$max["length"] = 0;  
$max["word"] = "";  
    for($i=0;$i < count($array);$i++)  
    {  
        if(strlen($array[$i]) > $max["length"])  
        {  
        $max["word"] = $array[$i];  
        $max["length"] = strlen($array[$i]);  
        }  
    }  
echo "   : <b>".$max["word"]."[".$max["length"]."]</b>";
}

Answer 1, authority 100%

program prog1;
{$APPTYPE CONSOLE}
var i, ws: integer;
    sentence, wmax: string;
begin
ReadLn(sentence);
sentence := Concat(sentence, ' ');
wmax := '';
ws := 1;
for i := 1 to Length(sentence) do
  if (sentence[i] = ' ') then begin
    if (i - ws > Length(wmax)) then
      wmax := Copy(sentence, ws, i - ws);
    ws := i+1;
    end;
WriteLn(wmax);
ReadLn;
end.

Delphi7, if anything

UPDoptimized a bit

UPD2especially for the author, checked version in turbo pascal. Looking for differences)

program prog1;
var i, ws: integer;
    sentence, wmax: string;
begin
ReadLn(sentence);
sentence := Concat(sentence, ' ');
wmax := '';
ws := 1;
for i := 1 to Length(sentence) do
  if (sentence[i] = ' ') then begin
    if (i - ws > Length(wmax)) then
      wmax := Copy(sentence, ws, i - ws);
    ws := i+1;
    end;
WriteLn(wmax);
ReadLn;
end.