Does anyone know of a way to retrieve the current date and time from the operating system? I'm using CLIPS 6.3 on a Windows platform.
Here's one way to retrieve the values as strings:
(deffunction system-string (?arg)
(bind ?arg (str-cat ?arg " > temp.txt"))
(open "temp.txt" temp "r")
(bind ?rv (readline temp))
CLIPS> (system-string "date /t")
"Sat 01/01/2011 "
CLIPS> (system-string "time /t")
Hi, i would like to know how to get only the year if it would be possible.
Thanks a lot
Once you've got the string with the date in it, just use the string manipulation functions:
CLIPS> (sub-string 11 14 "Sat 01/01/2011 ")