If then and loops
Michiel Spape
Michiel.Spape at nottingham.ac.uk
Thu Oct 20 07:26:40 UTC 2011
Avoiding pedantry:
In basic you can just
if (condition1 and condition2) then ... which works almost exactly the same as the & in C (but not &&, which would be if (condition1) {if (condition2) {...}}.
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-prime at googlegroups.com [e-prime at googlegroups.com] On Behalf Of Nick G [nick.gaspelin at gmail.com]
Sent: 20 October 2011 06:52
To: E-Prime
Subject: Re: If then and loops
You know in C you can just
if (condition1 && condition2)
On Oct 19, 11:47 pm, Nick G <nick.gaspe... at gmail.com> wrote:
> The E-basic help doesn't say whether an if-then statement can have
> multiple conditions. Seems limiting to not have that sort of
> functionality.
>
> -Nick
>
> On Oct 19, 11:15 pm, Peter Quain <pqu... at une.edu.au> wrote:
>
>
>
>
>
>
>
> > try searching e-basic help for "If...Then...Else (statement)". Note
> > the conditions under which you need to close the conditional with "End If"
>
> > At 04:05 PM 20/10/2011, you wrote:
>
> > >I'm having trouble with the below code. E-Prime seems to want a
> > >'then' statement immediately following the 'if' statement:
>
> > >if present.RESP = "z" and strHit2 = "aHi" or strHit2 = "aLo" strHit2 =
> > >"aMed" then
> > > Confidence.RESP = strHit2
>
> > >If one response on the present slide is selected, I just want E-Prime
> > >to allow one of the three responses in the string hits. How should
> > >this code look?
>
> > >--
> > >You received this message because you are subscribed to the Google
> > >Groups "E-Prime" group.
> > >To post to this group, send email to e-prime at googlegroups.com.
> > >To unsubscribe from this group, send email to
> > >e-prime+unsubscribe at googlegroups.com.
> > >For more options, visit this group at
> > >http://groups.google.com/group/e-prime?hl=en.
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
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.
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.
More information about the Eprime
mailing list