Re: SDL-News: Timers again


Subject: Re: SDL-News: Timers again
From: Andreas Prinz (Andreas.Prinz#hia.no)
Date: Thu Mar 04 2004 - 07:19:53 GMT


Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Andreas Prinz <Andreas.Prinz#hia.no> to sdlnews -----

Hello Keith,
the types Real, Time and Duration are completely distinct types.
However, they share the same set of literals. The are several ways of
conversion between them, which you can find in the Annex D of Z.100.
 From the current SDL-2000 I have extracted:

value type Duration;
literals unordered nameclass ('0':'9')+ or (('0':'9')* '.' ('0':'9')+);
operators
protected duration ( Real ) -> this Duration;
"*" ( this Duration, Real ) -> this Duration;
"*" ( Real, this Duration ) -> this Duration;
...
endvalue type Duration;

value type Time;
literals unordered nameclass ('0':'9')+ or (('0':'9')* '.' ('0':'9')+);
operators
protected time ( Duration ) -> this Time;
"+" ( this Time, Duration) -> this Time;
"+" ( Duration, this Time) -> this Time;
"-" ( this Time, Duration) -> this Time;
"-" ( this Time, this Time ) -> Duration;
...
endvalue type Time;

So either you try the operator duration or you try to multiply a
Duration 1.0 with the real you want to convert.

Hope that helps,
    Andreas

P.S.: Usually it is recommended to use Time and Duration for Timers, and
not to use Real.

KEMoss6#aol.com wrote:
> Hello all
>
> This time I'll try to state the problem more explicitly.
>
> If I have simple process consisting of:
> 1 the start symbol
> 2 A declaration of variable 'num' of type duration
> 3 A decaration of a time ts
> 4 A state fin
>
> The the SDL tool is quite happy. If however I change the type of 'num'
> to real it gets upset and gives the error message " Expression is not of
> expected data type time or the argument type(s) are wrong. This is
> despite duration iself being of type real. How do I convert a real
> number to a duration? Well that would solve it.
>
> Keith Moss

-- 
Prof. Andreas Prinz
Agder University College
Open Systems Development Group
Tel: +47 3725 3220
mailto: Andreas.Prinz#HIA.no

--End text from Andreas Prinz <Andreas.Prinz#hia.no> to sdlnews --- For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>



This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:50 GMT