next up previous contents index
Next: Using a network with Up: List of primitives Previous: Modify some properties of   Contents   Index

Time and date

XLogo has several primitives for date, time or generating countdown.
Primitives Arguments Use
wait n: whole number Halts the program, and therefore the turtle, for $ \frac{n}{60}$ seconds.
chrono, chronometre n: integer Starts a countdown of n seconds. We know if this countdown has finished with the primitive endcountdown?
endcountdown? none Returns "true if there's no active countdown. Returns "false if the countdown is active.
date none Returns a list wich contains three integers representing the date. The first integer indicates the day, the second the month and the last the year. --> [day month year]
time aucun Returns a list of three integers representing the time. The first integer indicates the hour, the second the minutes and the last the seconds. --> [hour minute seconde]
pasttime none Returns the past time in seconds since XLOGO has started.


Difference between wait and countdown is that countdown doesn't halt the program.

Here is an example:
to clock
# shows time in numerical format
# we refresh the time each five seconds
if endcountdown? [
cs 
sfont 75 ht
make "heu time
make "h first :heu
make "m item 2 :heu
# We shows two number for seconds and minutes. (we must add a 0)
if :m-10<0 [make "m word 0 :m]
make "s last :heu
# We shows two number for seconds and minutes. (we must add a 0)
if :s-10<0 [make "s word 0 :s]
label word word word word :h ": :m ": :s 
countdown 5
]
clock
end


next up previous contents index
Next: Using a network with Up: List of primitives Previous: Modify some properties of   Contents   Index
Loïc 2008-06-08