Board index » delphi » changing real type data to word type

changing real type data to word type

I want to instruct the computer to delay 3 seconds minus the value of a
reaction time variable.  The problem is that the delay function is of
word type and the RT variable is of real type.  I've tried creating a
function to make this conversion, as follows:

function get_delay (RTvar : real) : word;
   begin
   get_delay:=RTvar;
   end;
But I still get the type mismatch error.  I also tried using an
undefined variable to take the value of the RT variable, but htat didn't
work either.  There must be an easier way!

THanks,
Jon

 

Re:changing real type data to word type


In article <52mt8u$...@dismay.ucs.indiana.edu>,
jmarg...@ezinfo.ucs.indiana.edu says...

Quote
>I want to instruct the computer to delay 3 seconds minus the value of a
>reaction time variable.  The problem is that the delay function is of
>word type and the RT variable is of real type.  I've tried creating a
>function to make this conversion, as follows:
>function get_delay (RTvar : real) : word;
>   begin
>   get_delay:=RTvar;
>   end;
>But I still get the type mismatch error.  I also tried using an
>undefined variable to take the value of the RT variable, but htat didn't
>work either.  There must be an easier way!

>THanks,
>Jon

Just use the round function.
Hope this helps,
Jochen

Re:changing real type data to word type


Quote
Jonathan B Margolin wrote:

> function get_delay (RTvar : real) : word;
>    begin
>    get_delay:=RTvar;
>    end;
> But I still get the type mismatch error.  I also tried using an
> undefined variable to take the value of the RT variable, but htat didn't
> work either.  There must be an easier way!

there are *two* easy ways:
get_delay:=round(RTvar);
get_delay:=trunc(RTvar);

of course you'll have to check if RTVar is in the 0..65536 range;

--
Otavio Exel /<\oo/>\
oe...@economatica.com.br

Other Threads