increasing/decreasing percentage - pie chart/ circular graph

Matt Paffel mpaffel at gmail.com
Wed May 12 21:45:42 UTC 2010


Thank you guys, I wont be able to check the variations until tomorrow
afternoon. I'll let you know how it works out.

On May 12, 2:35 pm, David McFarlane <mcfar... at msu.edu> wrote:
> Susan,
>
> Good catch, I obviously missed that when I made & posted my revisions!
> Just for the record (and because I am such a pedant) here are all the
> code samples again with corrections made.  <editorial>AFAIK
> E-Basic/Visual Basic is the only language that has this silly rule about
> parentheses around Function arguments but not Sub arguments, which
> causes much pain for no useful purpose.  (For that matter, more rational
> languages such as C do away with the useless distinction between
> functions and subroutines altogether.)</editorial>
>
> First, my base revision of Mich's code (also adding more parentheses
> around conditional clauses, and putting tests into numerical order just
> because I think it reads better) (and please pay attention to the
> underscore "_" that I use at the end of some lines, yet another silly
> affectation of Basic)...
>
> If (mySlide.resp = 1) then  ' decrease pie slice
>      If c.GetAttrib("CurrentPerc") > 1 then _
>          c.SetAttrib "CurrentPerc", CInt(c.GetAttrib("CurrentPerc")) - 1
>      c.SetAttrib "myPicture", _
>          "pie" & cstr(c.GetAttrib("CurrentPerc")) & ".bmp"
>      goto Label1
> ElseIf (mySlide.resp = 2) then  ' increase pie slice
>      If c.GetAttrib("CurrentPerc") < 100 then _
>          c.SetAttrib "CurrentPerc", CInt(c.GetAttrib("CurrentPerc")) + 1
>      c.SetAttrib "myPicture", _
>          "pie" & cstr(c.GetAttrib("CurrentPerc")) & ".bmp"
>      goto Label1
> End If
>
> Then, my revision using a variable instead of an attribute reference for
> CurrentPerc (and this time giving a type to the variable)...
>
> Dim  currentPerc as Integer  ' Single would allow fractional changes
> If (mySlide.resp = 1) then  ' decrease pie slice
>      If (currentPerc > 1) then currentPerc = currentPerc - 1
>      c.SetAttrib "myPicture", "pie" & cstr(currentPerc) & ".bmp"
>      goto Label1
> ElseIf (mySlide.resp = 2) then  ' increase pie slice
>      If (currentPerc < 100) then currentPerc = currentPerc + 1
>      c.SetAttrib "myPicture", "pie" & cstr(currentPerc) & ".bmp"
>      goto Label1
> End If
>
> Then my exercise using Select...Case...
>
> Dim  currentPerc as Integer
> Select Case mySlide.RESP
> Case 1  ' decrease pie slice
>      If (currentPerc > 1) then currentPerc = currentPerc - 1
>      c.SetAttrib "myPicture", "pie" & cstr(currentPerc) & ".bmp"
>      goto Label1
> Case 2  ' increase pie slice
>      If (currentPerc < 100) then currentPerc = currentPerc + 1
>      c.SetAttrib "myPicture", "pie" & cstr(currentPerc) & ".bmp"
>      goto Label1
> End Select
>
> And finally, Mich reduced it all to (with me now adding the Dim, and
> making a correction to his literal constant value)...
>
> ' Assumes .RESP = 1 for decrease, .RESP = 3 for increase, otherwise
> ' algorithm will fail.
> Dim  currentPerc as Integer
> If IsNumeric(mySlide.RESP) then
>      If ((currentPerc + cint(mySlide.RESP) - 2) > 0) AND _
>          ((currentPerc + cint(mySlide.RESP) - 2) < 100) then _
>          currentPerc = currentPerc + cint(mySlide.RESP)- 2
>      c.SetAttrib "myPicture", "pie" & cstr(currentPerc) & ".bmp"
>      goto Label1
> End if
>
> Note that this all assumes that the Procedure runs until we are done
> with pie slices, otherwise we would have to work with a global variable.
>
> -- David McFarlane, Professional Faultfinder
>
>
>
> > Here's a thought: while c.GetAttrib takes parens, c.SetAttrib does
> > not; I believe the general form should be:
>
> > c.SetAttrib "CurrentPerc", "12"
>
> > or whatever. That should fix that particular error. You may also have
> > a problem because all attributes are strings, so conversion to integer
> > may be necessary in some places.
>
> > HTH,
> > Susan
>
> > On May 12, 12:37 pm, Matt Paffel <mpaf... at gmail.com> wrote:
> >> Arrrgggh!!!
>
> >> So I've spent the last couple of days trying to place the various code
> >> within the experiment. every time i try to do so i get the error
> >> messages "SetAttrib is not a property of the object" when i put any of
> >> the above script in or "CurrentPerc is not an assignable property of
> >> the object" when i try to set CurrentPerc as an attribute, any
> >> suggestions?
>
> --
> 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 athttp://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