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:
CLIPS> (deffunction system-string (?arg) (bind ?arg (str-cat ?arg " > temp.txt")) (system ?arg) (open "temp.txt" temp "r") (bind ?rv (readline temp)) (close temp) ?rv) CLIPS> (system-string "date /t") "Sat 01/01/2011 " CLIPS> (system-string "time /t") "05:34 PM" CLIPS>
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 ") "2011" CLIPS>
Log in to post a comment.
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:
CLIPS>
(deffunction system-string (?arg)
(bind ?arg (str-cat ?arg " > temp.txt"))
(system ?arg)
(open "temp.txt" temp "r")
(bind ?rv (readline temp))
(close temp)
?rv)
CLIPS> (system-string "date /t")
"Sat 01/01/2011 "
CLIPS> (system-string "time /t")
"05:34 PM"
CLIPS>
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 ")
"2011"
CLIPS>