GETDATE.PAS 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {* WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  2. Do not try to use the MsDos function call unless you are
  3. very familiar with the operating system and have technical
  4. information available to you!
  5. The following program uses the MsDos command in Turbo to
  6. retrieve the system date. This is achieved via DOS function
  7. call 42 (or 2A hex). The function call is placed in the AH
  8. register according to the technical reference manual.
  9. Type in the following code. The only output is the date
  10. at the top of your screen.*}
  11. program GetDate;
  12. type
  13. DateStr = string[10];
  14. function Date: DateStr;
  15. type
  16. regpack = record
  17. ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  18. end;
  19. var
  20. recpack: regpack; {record for MsDos call}
  21. month,day: string[2];
  22. year: string[4];
  23. dx,cx: integer;
  24. begin
  25. with recpack do
  26. begin
  27. ax := $2a shl 8;
  28. end;
  29. MsDos(recpack); { call function }
  30. with recpack do
  31. begin
  32. str(cx,year); {convert to string}
  33. str(dx mod 256,day); { " }
  34. str(dx shr 8,month); { " }
  35. end;
  36. date := month+'/'+day+'/'+year;
  37. end;
  38. begin
  39. writeln(date);
  40. end.