The following are functions that provide procedural programming capabilities as found in languages such as FORTRAN and C.
Important: In the descriptions below, items enclosed in square brackets [
] are optional. If you choose to include the optional
information, do not include the square brackets, only the items within them.
If...then...else function
CLIPS provides an
if...then...elsestructure to allow for conditional execution of a set of actions.The syntax is
(if <expression> then <action> [else <action>] )
Any number of allowable actions can be used inside of the
thenandelseportions, including otherif...then...elsestructures. Theelseportion is optional. If<expression>evaluates to anything other than the symbolFALSE, then the actions immediately following thethenare executed.Otherwise, the actions following the
elseare executed. Although theiffunction returns a value, it is not useful in Ansys Polyflow.Example:
This function sets the local variable
?Valto 3. if the variable?vis equal to 6, and sets?Valto 1. otherwise. In addition to=, you can use the comparison operators <, >,<=, and >=.(if (= ?v 6) then (bind ?Val 3.) else (bind ?Val 1.) )
While
The
whilefunction is provided to allow simple looping. Its use is similar to that of theiffunction.The syntax is
(while <expression>[do] <action>)
Any number of functions can be included in the
<action>. The symboldocan appear after the<expression>but it has no effect on the function.If
<expression>is evaluated toFALSE, then the function stops and does nothing. If<expression>is notFALSE, then<action>is executed. Then<expression>is reevaluated: ifFALSE, the function stops; if notFALSE,<action>is executed again, and the process continues until<expression>evaluates toFALSE.Example:
(while (< ?v 10) (bind ?v (- (* ?v ?v) 10)) )
This function take the value of
vand, if it less than 10, repeatedly replaces it with the value of-10untilvis greater than 10.Loop-for-count
The
loop-for-countfunction is provided to allow simple iterative looping.The syntax for this function is
(loop-for-count <range-spec>[do]<action>)
where
<range-spec>has the syntax<end-index> | (<loop-variable>[<start-index><end-index>])
where
<start-index>and<end-index>are integer expressions.Any number of functions and expressions can be included in the
<action>.Example 1:
(loop-for-count 5 (bind ?X1 (sin ?X1)))
This example replaces
?X1by the value of.
Example 2:
(deffunction PowerSeries4 (?x) (bind ?y 0) (loop-for-count (?Count 0 4) do (bind ?y (+ ?y (** ?x ?Count))) ) ?y )This example takes a number
and returns