Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Can you assign a variable as a delay?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TipsyCzar




PostPosted: Thu Nov 03, 2016 7:40 am   Post subject: Can you assign a variable as a delay?

What is it you are trying to achieve?
<I'm trying to assign an integer or real variable as a delay value>


What is the problem you are having?
<"Argument is the wrong type" appears on all delays that use variables (other delays are fine)>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Sample of the code>

Turing:


  var time1:real
  time1:= 2000
  var answer1:string

  put "Divide the time by half?"
  get answer1
         if answer1 = "yes" then
         time1:= time1 / 2
         end if

 delay (time1)



Please specify what version of Turing you are using
<4.1.1>
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Nov 03, 2016 9:30 am   Post subject: RE:Can you assign a variable as a delay?

delay() only takes integer values. You are trying to give it real values.

If you need precision to fractions of a millisecond, then you will need to convert the real to an int on the fly by calling delay (int (time1)). Otherwise, just change time1 to an int and you'll be fine.
lordroba




PostPosted: Sat Nov 05, 2016 3:38 pm   Post subject: Re: Can you assign a variable as a delay?

You can use the round function

Turing:

delay  (round (time1))
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: