SlideStates

David McFarlane mcfarla9 at msu.edu
Mon Aug 23 15:59:40 UTC 2010


Arrgh, another overuse of If...End If for mutually exclusive 
possibilities, where ElseIf & Else, or Select...Case (not to mention a 
bit of indentation) would clarify the code tremendously.  Please consider

If c.GetAttrib("GamePlay") = "Default" Then
     Set Slide1.ActiveState = "Default"
ElseIf c.GetAttrib("GamePlay") = "Lose" Then
     If CInt(c.GetAttrib("FinalPie")) = 100 Then
         Set Slide1.ActiveState = "Default"
     Else
         Set Slide1.ActiveState = "Lose"
     End If
ElseIf c.GetAttrib("GamePlay") = "Victory" Then
     Set Slide1.ActiveState = "Victory"
Else
     MsgBox "Oops!  Invalid value for GamePlay"
End If

or

Select c.GetAttrib("GamePlay")
Case "Default"
     Set Slide1.ActiveState = "Default"
Case "Lose"
     If CInt(c.GetAttrib("FinalPie")) = 100 Then
         Set Slide1.ActiveState = "Default"
     Else
         Set Slide1.ActiveState = "Lose"
     End If
Case "Victory"
     Set Slide1.ActiveState = "Victory"
Case Else
     MsgBox "Oops!  Invalid value for GamePlay"
End Select

Isn't that better?  Then again, this whole bit of logic might be 
collapsed to simply something like

If CInt(c.GetAttrib("FinalPie")) = 100 Then
     Set Slide1.ActiveState = "Default"
Else
     Set Slide1.ActiveState = c.GetAttrib("GamePlay")
End If

(without the validity check), or even

Set Slide1.ActiveState = Iif( (CInt(c.GetAttrib("FinalPie")) = 100), _
     "Default", c.GetAttrib("GamePlay") )

Regards,
-- David McFarlane, Professional Faultfinder


Matt Paffel wrote:
> problem solved by inserting If...Then statement:
> 
> If c.GetAttrib("GamePlay") = "Default" Then
> Set Slide1.ActiveState = "Default"
> End If
> If c.GetAttrib("GamePlay") = "Lose" Then
> If CInt(c.GetAttrib("FinalPie")) = 100 Then
> Set Slide1.ActiveState = "Default"
> Else
> Set Slide1.ActiveState = "Lose"
> End If
> End If
> If c.GetAttrib("GamePlay") = "Victory" Then
> Set Slide1.ActiveState = "Victory"
> End If

-- 
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