need help in CLIPS programming

133 views
Skip to first unread message

raninder dhillon

unread,
Feb 6, 2012, 1:15:54 AM2/6/12
to CLIPSESG
hello..
I am facing some problem using CLIPS software. Actually i am making
some project in CLIPS which will read values from a text file , apply
rules on that values and store result in another text file. I am
using .bat file to read values,and loading .clp file for rules. The
problem is read-number function reads one value at a time. to read 10
values, i want to make use of loop

(open "ex.txt" num "r")
(bind ?count 0)
(while (<= ?count 9)
(bind ?ans(read-number num))

now ?ans stores one value,and next time when count becomes 1,it reads
another value such that previous value of ?ans get overwritten. I dont
want to use statement (bind ?ans(read-number num) 10 times... i want
to use ans as an array variable,so that all 10 values get stored on
which i can further apply rules. but i am unable to find array option
in CLIPS. can you help me how to do this?

CLIPS Support

unread,
Feb 10, 2012, 12:56:43 AM2/10/12
to CLIPSESG
If you write all of the values to a single line, you can read the
entire line using the deadline function and convert it to a multifield
value using the explode$ function.

CLIPS> (open "data.txt" data "w")
TRUE
CLIPS> (printout data "1 2 3 4 5 6 7 8 9 10" crlf)
CLIPS> (close data)
TRUE
CLIPS> (open "data.txt" data)
TRUE
CLIPS> (explode$ (readline data))
(1 2 3 4 5 6 7 8 9 10)
CLIPS> (close data)
TRUE
CLIPS>

On Feb 6, 12:15 am, raninder dhillon <raninderdhil...@gmail.com>
wrote:

Raninder Dhillon

unread,
Feb 10, 2012, 4:35:54 AM2/10/12
to clip...@googlegroups.com
Thanks sir..i tried your suggestion but the problem is after reading values one by one, i have to assert as facts like reading first no. suppose 2, i have  to store it as var1 2 as fact, then  next value suppose 5 as another fact var2 5 ans so on...till 10 values. After asserting as 10 variables, i have to apply rules on them like 
(defrule check1
(var1 ?v1)
(var2 ?v2)
test(> ?vr1 ?vr2)=> (printout t "rule violated" crlf))

how can this be done??

--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en

--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe

Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.

Reply all
Reply to author
Forward
0 new messages