If...Or...Then

Peter Quain pquain at une.edu.au
Thu Sep 23 22:19:49 UTC 2010


tis not eprime, tis messy code and/or list values.

  One example - Printing FeedBack3 value when you 
think it is FeedBack2: Debug.Print "FeedBack2 was"&c.GetAttrib("FeedBack3")

At 08:10 AM 24/09/2010, you wrote:
>update: Here's something interesting. I was in the process of
>rewritting the script and as I was working through it
>I noticed that Attrib("FeedBack1"), ("FeedBack2") and ("FeedBack3")
>weren't always being referenced properly.
>I took out all the script that woudl change any of the programming and
>debugged using this script:
>
>Debug.Print "FeedBack1 was"&c.GetAttrib("FeedBack1")
>Debug.Print "FeedBack2 was"&c.GetAttrib("FeedBack3")
>Debug.Print "FeedBack3 was"&c.GetAttrib("FeedBack3")
>
>what I found was that half the cases the feedback2 was the wrong
>number, feedback1 was wrong only 2x, and
>feedback3 was never referenced incorrectly. have either of run into
>this? I'm currently using 2.8.79 if that makes 3
>any difference.
>
>On Sep 23, 9:26 am, Matt Paffel <mpaf... at gmail.com> wrote:
> > I knew this was going to raise some 'brows when i posted it and I
> > thank you both for the advice.
> > i was actually going to make a table this afternoon when i got into
> > the office just to see if i could work it out
> > on paper first and then retry. I'll let you know how it goes and
> > again, thank you.
> >
> > On Sep 23, 8:52 am, David McFarlane <mcfar... at msu.edu> wrote:
> >
> >
> >
> > > Matt,
> >
> > > I second Mich's sentiment, and will use stronger language -- your code
> > > is a horrible mess!  It is just plain ugly!  People may complain that I
> > > harp too much on the virtue of making code "beautiful", but I find that
> > > making code beautiful also often makes it just work better, and many
> > > code problems result just from ugliness.  So...
> >
> > > - Your code is yet another ugly case of using multiple If...End If
> > > instead of If...ElseIf...Else...End If.  I will leave this as an
> > > exercise for you.  See the online E-Basic Help, and my many other
> > > complaints about this here on the Google Group.
> >
> > > - Better yet, as Mich hinted, see if you can cast this into a
> > > Select...Case structure.
> >
> > > - As Mich also said, use parentheses liberally.  I just had a private
> > > argument with Brandon Cernicky at PST about this very issue, you prove
> > > my point that more parentheses are generally desirable.
> >
> > > - Even better, looking at your code it looks like you actually have a
> > > cascade of several different conditions.  In that case, just reorganize
> > > this into a set of nested If...Then or Select...Case.  That could also
> > > eliminate the And clause, possibly 
> more.  So, something along the lines of
> >
> > > Select LotteryChoice.RESP
> > > Case 1
> > >      If ((c.GetAttrib("FeedBack1") = "0") OR _
> > >          (c.GetAttrib("FeedBack2") = "0") OR _
> > >          (c.GetAttrib("FeedBack3") = "0")) Then _
> > >          Set Slide1.ActiveState = "Default1"
> > >      ....
> > > Case 2
> > >      ....
> > > Case 3
> > >      ....
> > > Case Else
> > >      MsgBox "Invalid LotteryChoice.RESP"
> > > End Select
> >
> > > - Finally, before you even set about to code this any further, first sit
> > > down and make a complete logic table of all the combinatoric conditional
> > > possibilities and the desired result for each combination.  You have a
> > > small finite set of conditions, so this should not take much trouble.  I
> > > do this all the time whenever I face a similar situation, it really
> > > helps to untangle the logic and then I can code it rationally and
> > > quickly.  And if you do not understand what I am talking about, then
> > > take a class that covers propositional (i.e., Boolean) logic and
> > > combinatorics, its not that hard.
> >
> > > -- David McFarlane, Professional Faultfinder
> >
> > > Michiel Spape wrote:
> > > > Hi,
> > > > It gives me headache just looking at it! 
> I'm sure David mcF would be better at cleaning this up, but:
> > > > 1. try to separate multiple AND/ORs using 
> brackets, unless you're REALLY sure about 
> eBasic's priority: does AND go before =, does 
> equal go before OR, does AND go before OR? I'm 
> assuming you mean IF (LotteryChoice.RESP = "1" 
> and (c.GetAttrib("Feedback1") = "0" or 
> c.GetAttrib("Feedback2") = "0" or c.GetAttrib("Feedback3") = "0") then.
> > > > 2. AND ...(c.GetAttrib("Feedback1") = "0" OR ... etc
> > > > Is the same as c.GetAttrib("Feedback1") * 
> c.GetAttrib("Feedback2") * c.GetAttrib("Feedback3") = 0. Awesome trick, no?
> > > > 3. how about:
> > > > ----
> > > > If (c.GetAttrib("FeedBack1") * 
> c.GetAttrib("FeedBack2") * c.GetAttrib("Feedback3")) = 0 then
> > > >   Set Slide1.ActiveState = "Default" & 
> LotteryChoice.RESP ' ...assuming it can be 1 to 3
> > > > End if
> > > > ....
> > > > 4. Do stuff with else and cases. Also, you might wish to nest bits.
> > > > 5. The problem, if you say every IF here 
> turns out wrong is indeed either in your ifs, 
> so you need to clean those up, or in the 
> premises (LotteryChoice.RESP, 
> c.GetAttrib("Feedback")). Why don't you 
> debug.print what the answer to the premises is?
> > > > Debug.print "LotteryChoice.RESP was " & LotteryChoice.RESP
> > > > Debug.print "Feedback1 was: " & c.GetAttrib("Feedback1").
> > > > If it so happens that these are correctly 
> found at the level of your script, and your IF 
> statements still all turn false, then your IF 
> statements are false, so your IF-THENs are not 
> working (I also make messy ones from time to time!).
> > > > Cheers,
> > > > Mich
> >
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "0"
> > > >  OR c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0"
> > > > Then
> > > >  Set Slide1.ActiveState = "Default1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "0" OR
> > > > c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0" Then
> > > >  Set Slide1.ActiveState = "Default2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "0" OR
> > > > c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0" Then
> > > >  Set Slide1.ActiveState = "Default3"
> > > > End If
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory3"
> > > > End If
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose3"
> > > > End If
> >
> > > > Michiel Spap�
> > > > Research Fellow
> > > > Perception & Action group
> > > > University of Nottingham
> > > > School of Psychology
> > > >www.cognitology.eu
> >
> > > > -----Original Message-----
> > > > From: e-prime at googlegroups.com 
> [mailto:e-prime at googlegroups.com] On Behalf Of Matt Paffel
> > > > Sent: 22 September 2010 22:35
> > > > To: E-Prime
> > > > Subject: If...Or...Then
> >
> > > > Hello
> >
> > > > I have Multiple slideslates that I'm tring to change based on the
> > > > script below, however the script isn't performing as I'd like it to.
> >
> > > > The message from the output window after debugging states:
> >
> > > > 3Lose3
> > > > False
> > > > 2Lose3
> > > > False
> > > > 1Lose3
> > > > False
> >
> > > > This tells me that it's collecting the responses correctly and setting
> > > > a slide state but it looks as though the program is going through the
> > > > arguments and declaring them all false, which is not the case. Is
> > > > there something I need to include as the arguments make use of the
> > > > "OR" statement or is something else such as my overzealous use of the
> > > > If...Then statement?
> >
> > > > Note: I've added indents here to make it easier to look at.
> >
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "0"_
> > > >  OR c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0"
> > > > Then
> > > >  Set Slide1.ActiveState = "Default1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "0" OR
> > > > c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0" Then
> > > >  Set Slide1.ActiveState = "Default2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "0" OR
> > > > c.GetAttrib("FeedBack2") = "0" OR c.GetAttrib("FeedBack3") = "0" Then
> > > >  Set Slide1.ActiveState = "Default3"
> > > > End If
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "1" OR
> > > > c.GetAttrib("FeedBack2") = "1" OR c.GetAttrib("FeedBack3") = "1" Then
> > > >  Set Slide1.ActiveState = "Victory3"
> > > > End If
> > > > If LotteryChoice.RESP = "1" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose1"
> > > > End If
> > > > If LotteryChoice.RESP = "2" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose2"
> > > > End If
> > > > If LotteryChoice.RESP = "3" And c.GetAttrib("FeedBack1") = "2" OR
> > > > c.GetAttrib("FeedBack2") = "2" OR c.GetAttrib("FeedBack3") = "2" Then
> > > >  Set Slide1.ActiveState = "Lose3"
> > > > End If- Hide quoted text -
> >
> > - Show quoted text -
>
>--
>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.



More information about the Eprime mailing list