Re: Real Time IO routines



Ada Purist never and I mean NEVER uses IMAGE attribute, in the body of
a program. They create a package or sub-package that performs the IO
functions with the use of the IMAGE attribute.

IMAGE attribute is the last thing a programmer should use. to print a value.
It is normally use for DEBUGGING ONLY! A programmer should always create
a routine or better yet a package that uses an algorithm to prints the value
without the use of attributes.

Mostly programs that are created by newbees use IMAGE attribute.


And as for my code! It answer the person question without adding extra
code that might confuse him. Plus, the "Ada.Real_Time" package uses:

type Time is new Duration;

which is in private section. So I know what to convert the value to.

In <ddn82trtef34$.n1ulcxn4se96.dlg@xxxxxxxxxx>, "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> writes:
On Sat, 27 Oct 2007 08:56:42 GMT, anon wrote:

function To_Duration is new Ada.Unchecked_Conversion
( Time, Duration ) ;

That is a bad idea. You don't know what is the internal representation of
Time. The intended effect can be achieved legally:

with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;

procedure Test is
function Image (T : Time) return String is
Seconds : Seconds_Count;
Fraction : Time_Span;
begin
Split (T, Seconds, Fraction);
declare
After : constant String :=
Duration'Image (To_Duration (Fraction));
begin
return Seconds_Count'Image (Seconds) & After (2..After'Last);
end;
end Image;
begin
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
end Test;

--------------------
However it is quite useless to output absolute time values involving an
unknown epoch. Unfortunately there is no portable way I know of to convert
Real_Time.Time to UTC.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

.



Relevant Pages

  • Re: PowerEdge SC600 memory upgrade
    ... systems with Quickbooks 4 and the trash software, ... when I informed them that a software conversion to a newer custom ... CSV or other type file format, then have a programmer or perhaps the company ... whatever package they would like to buy will end up using addition/different ...
    (alt.sys.pc-clone.dell)
  • Re: Literate Programming in Ada, AdaDoc, AdaBrowse
    ... This is my idea of what the beginning of a package specification might look ... the Titian term for them is that they have *'direct color'. ... The latter option will be more efficient for contexts which do not have direct ... the programmer could program two different algorithms for contexts ...
    (comp.lang.ada)
  • Re: Your strategies for managing code writing?
    ... whatever thats still up to the programmer itself. ... Delphi actually supports ... you could instead make one package and add all your units to that package, ... Bad -> requires lot's of space, a versioning system can safe space by only ...
    (alt.comp.lang.borland-delphi)
  • Privilege in scheduling packages through sql agent jobs
    ... A programmer can schedule jobs through sql agent and the job step that is ... programmer runs the package interactively, ...
    (microsoft.public.sqlserver.security)
  • Re: Real Time IO routines -- answering Simon Wright part 1
    ... -- use of enumeration Boolean package and using the IMAGE attribute ... -- A) Full width control. ... -- I/O package for Boolean type. ... -- a routine in a programmer created package. ...
    (comp.lang.ada)