Re: if else if

354 views
Skip to first unread message

Sagar Tikke

unread,
Nov 29, 2012, 1:19:42 AM11/29/12
to clip...@googlegroups.com
if (){

}
else if(){

}

else if(){

}

else
{

}

On 11/29/12, Ahmed Abdeen Hamed <ahmed....@gmail.com> wrote:
> Hello,
>
> What is the syntax for if else if?
>
> I am trying to do the following: The first two functions are called in the
> third. The third has a else but I am unable to make it else if. Can anyone
> take kindly a look at this and let me know?
>
> Sincerely,
>
> -Ahmed
>
> (deffunction minutes_diff
> (?arrival_minutes ?departure_minutes)
> (- ?departure_minutes ?arrival_minutes))
>
> (deffunction hours_diff
> (?arrival_hour ?departure_hour)
>
> (* (- ?departure_hour ?arrival_hour ) 60))
>
> (deffunction minutes_to_next_flight
> (?arrival_hour ?arrival_minutes ?departure_hour ?departure_minutes)
>
> (if (> (hours_diff ?arrival_hour ?departure_hour) 0)
> then
> (-
> (hours_diff ?arrival_hour ?departure_hour)
> (minutes_diff ?arrival_minutes ?departure_minutes)
> )
>
> else ;(if (<= (hours_diff ?arrival_hour ?departure_hour) 0) IS
> NEEDED!!!
> (-
> (minutes_diff ?arrival_minutes ?departure_minutes)
> (hours_diff ?arrival_hour ?departure_hour)
>
> )))
>
> --
> 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.

Ahmed Abdeen Hamed

unread,
Nov 29, 2012, 12:04:28 PM11/29/12
to clip...@googlegroups.com
Thank you for the response. The syntax you provided is C-like not CLIPS though. I needed CLIPS syntax.

-Ahmed

alexgian

unread,
Nov 29, 2012, 9:25:49 PM11/29/12
to clip...@googlegroups.com
From the manual:

12.6.2 If...then...else Function

The if function provides an if...then...else structure to allow for conditional execution of a set of actions.

Syntax

(if <expression>
   then
      <action>*
   [else
      <action>*])

 

Any number of allowable actions may be used inside of the then or else portion, including another if...then...else structure. The else portion is optional. If <expression> evaluates to anything other than the symbol FALSE, then the actions associated with the then portion are executed. Otherwise, the actions associated with the else portion are executed. The return value of the if function is the value of the last <expression> or <action> evaluated.


=====

So it seems to me you didn't put the "then" clause in your second if statement
Reply all
Reply to author
Forward
0 new messages