Move trhough a list forward and backward

133 views
Skip to first unread message

Er...@ericwalden.net

unread,
Sep 12, 2013, 5:34:21 AM9/12/13
to e-p...@googlegroups.com
I have an experiment with a list object and I would like to move both forward and backward through the list depending on the keyboard input. In other words, a 1 moves backwards and a 2 moves forwards in the list. Below is the code I have that is not working. This occurs after I display the list item, so the list index has already advanced from 0 to 1. First, I get the current index (which works fine) then I check to see if it is greater than 1 (i.e. 2 or more) because I can't go backwards if I am at the first item. If the response = 1 then I set a new variable called NewIndex which is the currentindex -2 (because it has already advanced).

Then I try to set the attribute value back to the new attribute value. But for some reason, that does not work.

How can I manually set the index of the current list?

' My list is called
ListOfComputers, and it is a list of computers (the task is computer shopping and subjects need to be able to move back and forth

CurrentIndex = c.GetAttrib("ListOfComputers")

'Check to make sure we are far enough along the list to move backwards
if CurrentIndex > 1 then
   if ShowMovie.RESP = 1 then
'Use -2 instead of minus one because the in line code occurs after the presentation slide so the list index has already advanced one space
     NewIndex = CurrentIndex - 2
     c.SetAttrib "ListOfComputers", NewIndex
   end if
end if

' This message box shows all of the variables with the values I want, it just does not actually change where on the list the next stimuli occurs.  In other words it just keeps running through the list in the predefined order
msgbox("CurrentIndex = " & CurrentIndex & " NewIndex = " & NewIndex &" ShowMovie.RESP = " & ShowMovie.RESP)

David McFarlane

unread,
Sep 12, 2013, 5:05:47 PM9/12/13
to e-p...@googlegroups.com
I think you will just have to pull your attributes from the List as
needed manually in code using List.GetAttrib, see that topic in the
E-Basic Help facility. E.g., suppose you have a List named MyList,
with attributes MyAttrib1 and MyAttrib2, you use the variable iList
(possibly global) for your List index, and you already have code to
change iList as needed. Then you would load your attributes with

c.SetAttrib "MyAttrib1", MyList.GetAttrib(iList, "MyAttrib1")
c.SetAttrib "MyAttrib2", MyList.GetAttrib(iList, "MyAttrib2")

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (https://twitter.com/EPrimeMaster)

/----
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours, so make full use of
it. 3) In addition, PST offers several instructional videos on their
YouTube channel (http://www.youtube.com/user/PSTNET ). 4) If you do
get an answer from PST staff, please extend the courtesy of posting
their reply back here for the sake of others.
\----

iva...@hotmail.fr

unread,
Nov 6, 2017, 6:38:56 AM11/6/17
to E-Prime
Hello !
It's been a long time this question was posted but I want to build an experiment with the possibility to go backward and forward through the list.
I was wanderring if you have finally found a solution ?

Thank you in advance and have a good day !

Ivane
Reply all
Reply to author
Forward
0 new messages