>--
>You received this message because you are subscribed to the Google
>Groups "E-Prime" group.
>To post to this group, send email to e-p...@googlegroups.com.
>To unsubscribe from this group, send email to
>e-prime+u...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/e-prime?hl=en.
-----------------------
Syntax 1
If condition Then statements [Else else_statements]
Syntax 2
If condition Then
[statements]
[ElseIf else_condition Then
[elseif_statements]]
[Else
[else_statements]]
End If
-------------------------
Description
Conditionally executes a statement or group of statements.
Comments
The single-line conditional statement (syntax 1) has the following parameters:
Parameter Description
condition Any expression evaluating to a Boolean value.
statements One or more statements separated with colons. This
group of statements is executed when condition is True.
else_statements One or more statements separated with colons. This
group of statements is executed when condition is False.
The multiline conditional statement (syntax 2) has the following parameters:
Parameter Description
condition Any expression evaluating to a Boolean value.
statements One or more statements to be executed when condition is True.
else_condition Any expression evaluating to a Boolean value. The
else_condition is evaluated if condition is False.
elseif_statements One or more statements to be executed when
condition is False and else_condition is True.
else_statments One or more statements to be executed when both
condition and else_condition are False.
-------------------------------
' Dimension the variable. Dim x As Integer ' Place a value in x. x = Int(Rnd * 100) ' Display the value of x. MsgBox "The value of x is " & x & "." ' Test to see if x less than or equal to 10. If x <= 10 Then ' Display a message box. MsgBox "X is <=10" ' Test to see if x less than or equal to 40 and greater than 10. ElseIf x <= 40 And x > 10 Then MsgBox "X is <=40 and > 10" ' Test to see if x less than or equal to 70 and greater than 40. ElseIf x <= 70 And x > 40 Then MsgBox "X is <=70 and > 40" ' Test to see if x less than or equal to 100 and greater than 70. ElseIf x <= 100 And x > 70 Then MsgBox "X is <= 100 and > 70" ' If none of the above tests returned true. Else MsgBox "X does not fall within the range" End If
Anyway, the answer is much shorter:
IF (present.RESP = "z" and strHit2 = "aHi") or (strHit2 = "aLo" and strHit2 = "aMed") THEN
Confidence.RESP = strHit2
END IF
Note the end if. All on one line is also possible, but note it freaks out if you then use end if. THIS is what is exasperating - if not necessarily limitating - about ebasic.
More likely, your code makes no sense in some other degree, though. Notice me putting in the brackets - they are useless - and comes before or anyway - but i think where you got stuck was in the length of the IF statement. I mean, strHit2 is never both aLo and aMed, right? In your original code it did not have an operator (or strHit2 = "aLo" strHit2 = ?), so, given a wild guess, you actually want something like this:
IF present.RESP = "z" and (strHit2 = "this" or strHit2 = "that" or strHit2 = "nothisactually") THEN
Confidence.RESP = strHit2
END IF
Notice that due to the precedence of and over or - both in C and basic - this is possible, but your previous code made little sense.
Best,
Mich
________________________________________
From: e-p...@googlegroups.com [e-p...@googlegroups.com] On Behalf Of Nick G [nick.g...@gmail.com]
Sent: 20 October 2011 06:52
To: E-Prime
Subject: Re: If then and loops
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.