Re: stuck on my assignment (very beginner)

Posted by glenn on March 16, 2005

In Reply to: Re: stuck on my assignment (very beginner) posted by Jenny on March 14, 2005

thanks for your help. I have done this code, but it doesnt seem to work :(

function Time2400ToAmPm(T: string): string;
var
  H, M, AmPm: string;
begin
  writeln ('Please write the time in 24hour mode');
  readln (ampm);
  H := Copy(T, 1, 2);
  M := Copy(T, 3, 2);
  if StrToInt(H) > 12 then begin
    AmPm := 'pm';
    H := IntToStr(StrToInt(H) - 12);
  end
  else 
    AmPm := 'am';
  writeln(h,':',m,ampm);
  AmPm := 'am';
  Result := H + ':' + M + ' ' + AmPm;
  readln;
  writeln('press any key to continue');
  readln;
end;

Related Articles and Replies

 

Delphi Forum :: Tutorials :: Source code :: Tips