Is there a word to count clock timing in msec?

If you have any questions, remarks, ... if you need help... its here...

Is there a word to count clock timing in msec?

Postby bobgillies » 14 Feb 2017 00:47

I'm looking for a word that will pause a task for a number of milliseconds.

// pause task for half a second.
500 MSEC

EDIT: I found what I'm looking for in the CONSOLE chapter of the manual.
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Is there a word to count clock timing in msec?

Postby Franck » 14 Feb 2017 10:27

If related to reading a key, yes, this is into the console chapter.

If you want to wait for 500 ms, there is #sleep :
Code: Select all
500 sleep
Franck
 
Posts: 161
Joined: 29 Oct 2014 19:01

Re: Is there a word to count clock timing in msec?

Postby bobgillies » 14 Feb 2017 11:53

Thank you Franck. I thought I had found what I needed but ended up having issues. I'll use #sleep function.

Regards,
Bob
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Is there a word to count clock timing in msec?

Postby bobgillies » 14 Feb 2017 12:28

I'm curious as to why these two code snippets, DANCE1 and DANCE2, behave differently in their timing. Dance1 steps properly but dance2 is too fast. What is the reason?

import: os

: cls
"cls" _system drop ;

tvar: count

200 to count

: q1 "Q . . . . . . . " ;
: q2 ". Q . . . . . . " ;
: q3 ". . Q . . . . . " ;
: q4 ". . . Q . . . . " ;
: q5 ". . . . Q . . . " ;
: q6 ". . . . . Q . . " ;
: q7 ". . . . . . Q . " ;
: q8 ". . . . . . . Q " ;

: dance1
q1 . count sleep cls
q2 . count sleep cls
q3 . count sleep cls
q4 . count sleep cls
q5 . count sleep cls
q6 . count sleep cls
q7 . count sleep cls
q8 . count sleep cls
;

: dance2
| queen |
[q1 q2 q3 q4 q5 q6 q7 q8] forEach: queen [ queen . count sleep cls ]
;
bobgillies
 
Posts: 60
Joined: 24 Jan 2017 06:26

Re: Is there a word to count clock timing in msec?

Postby Franck » 14 Feb 2017 16:55

You need #, word to separate items of a declared array :

Code: Select all
: dance2
| queen |
[q1, q2, q3, q4, q5, q6, q7, q8] forEach: queen [ queen . count sleep cls ]
;


I suggest you to declare the array outside the function in order to not create a new array each time you call #dance2
Also, here, you could use #apply with a block that will be performed for each of the array

Code: Select all
[q1, q2, q3, q4, q5, q6, q7, q8] const: DANCE

: dance3
   #[ . count sleep cls ] DANCE apply ;


Franck
Franck
 
Posts: 161
Joined: 29 Oct 2014 19:01


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron