increasing/decreasing percentage - pie chart/ circular graph

Matt Paffel mpaffel at gmail.com
Fri Jun 11 16:02:46 UTC 2010


Here's an update on the script which allows the participant to go
between 0 and 100 and vice versa:

If (mySlide.resp = 1) Then  ' decrease pie slice
     If c.GetAttrib("CurrentPerc") > 0  Then
         c.SetAttrib "CurrentPerc", CInt(c.GetAttrib("CurrentPerc")) -
1
	 Else
		c.SetAttrib "CurrentPerc", CInt(100)
		End If
     c.SetAttrib "myPicture", _
         "pie/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
	Else
		c.SetAttrib "CurrentPerc", CInt(0)
		End If
	c.SetAttrib "myPicture", _
         "pie/pie" & cstr(c.GetAttrib("CurrentPerc")) & ".bmp"
     goto Label1
End If


Also, if anyone knows how i could get the program to start at say, 50%
on each trial I woudl greatly appreciate your help.


On Jun 9, 3:46 pm, Matt Paffel <mpaf... at gmail.com> wrote:
> from PST:
>
> Since you're keeping your bmps with pie slices in a folder called pie,
> you need to add this layer of the path to the image files into the
> code. The new code should look like this (all I did was change
> c.SetAttrib "myPicture", "pie" & cstr(c.GetAttrib("CurrentPerc")) &
> ".bmp"
> to
> c.SetAttrib "myPicture", "pie/pie" & cstr(c.GetAttrib("CurrentPerc"))
> & ".bmp"
> ) :
>
> 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/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/pie" & cstr(c.GetAttrib("CurrentPerc")) & ".bmp"
> goto Label1
> End If
>
> You need to add 3 to the Allowable field on mySlide's Duration/Input
> tab of the Property Pages or the "3 to confirm" option on your
> pictures will not work.
>
> Thank you again everyone.
>
> On May 13, 4:43 pm, Matt Paffel <mpaf... at gmail.com> wrote:
>
>
>
> > Hello...again. Sorry for taking up so much time with this but I’ve
> > entered the code and when I generate it, there seems to be no problem,
> > the code generates just fine. However, when I try to run the program,
> > I keep getting the error message 13, “type mismatch”. I then put all
> > the various 1’s and 2’s in quotation marks which allow me to not only
> > generate the code, but also run the program. However, the program does
> > not respond to any of the keys pressed, which inevitably leads me to
> > have to ctrl, alt, shift out of the program. After looking at it, one
> > of my colleagues suggested I place the entire code online for whomever
> > to look at and see if they can make it work. I’m not sure of the
> > etiquette of this and have opted against doing so but if anyone would
> > be willing to take a shot at it I can certainly do so. Does anyone
> > have a suggestion of where to go from here?
>
> > On May 13, 2:04 pm, David McFarlane <mcfar... at msu.edu> wrote:
>
> > > OK, by now you are all sick of this, but I couldn't let that last
> > > sample code sit, so as yet another exercise I revised it so that it
> > > will use .RESP = 1 for decrease and .RESP = 2 for increase (but as a
> > > further exercise, think through what happens if .RESP goes outside
> > > that range; of course one could prevent that by proper use of
> > > Allowable).  Note the use of CSng().  Remember, you are responsible
> > > for catching typos and making your own corrections in any of the free
> > > and hastily-produced sample code posted here.
>
> > > Dim  currentPerc as Integer, newPerc as Integer
> > > If IsNumeric(mySlide.RESP) Then
> > >      newPerc = currentPerc + (2 * ( CSng(mySlide.RESP) - 1.5 ))
> > >      If (0 <= newPerc) and (newPerc <= 100) Then
> > >          currentPerc = newPerc
> > >          c.SetAttrib "myPicture", "pie" & Cstr(newPerc) & ".bmp"
> > >      End If
> > >      goto Label1
> > > End if
>
> > > -- David McFarlane, Professional Faultfinder
>
> > > At 5/12/2010 03:35 PM Wednesday, David McFarlane 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 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 athttp://groups.google.com/group/e-prime?hl=en.-Hidequoted 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 athttp://groups.google.com/group/e-prime?hl=en.-Hide quoted text -
>
> > - Show quoted text -- 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.



More information about the Eprime mailing list