What is the current row in a list

David McFarlane mcfarla9 at msu.edu
Mon Feb 23 19:42:00 UTC 2009


At 2/23/2009 12:02 AM Monday, Peter Quain wrote:
>i spose you could add an attribute to your list(s) .. say called
>'lstsample' and number sequentially.. and then grab that value
>sss = [ListName].GetCurrentAttrib("lstsample")

Yes, even I shot my mouth off a little too soon (I was at home over 
breakfast, now I made it to my work site).  Peter actually has the 
most serviceable answer here, although there is a slightly slicker 
approach that may work.  And the previous answers using ".Sample" are 
not strictly correct, although it may by accident work in some 
cases.  Let me explain.

Suppose you have a List named List1.  When you run that list, you 
will find three related columns in the resulting .edat file:  List1, 
List1.Cycle, and List1.Sample.  If you only run one cycle of List1, 
*and* run in sequential order, *then* List1.Cycle will always show 1, 
and List1 will always equal List1.Sample.  However, if you run in 
random order, List1.Cycle will still always show 1 *but* List1 will 
only equal List1.Sample in the event that the "random" order turns 
out to be sequential, otherwise the values in these two attributes 
will differ -- List1.Sample will always show sequential values, 
whereas List1 will show which random row of List1 was selected for 
that iteration of the list.  Finally, if you run for more than one 
cycle, then, regardless of whether you use sequential or random 
selection, List1.Cycle will show which cycle of the list is running, 
and after cycle 1 then List1 will *never* equal List1.Sample -- i.e., 
List1.Sample will continue to increase sequentially, while List1 
again shows which row of the list was selected for that iteration of the list.

Whew!  So how do we summarize all that?
- The attribute "List1" shows which row of the list has been selected 
for the current iteration of List1.
- The attribute "List1.Cycle" shows which repetition of List1 in in progress.
- The attribute "List1.Sample" shows how many times we have taken a 
sample from List1 so far.  (This attribute is always strictly 
increasing, and in some cases could be used for a built-in trial 
counter, though in general you would to better using your own script 
variable for that.)

So, after all that, Greg could use something like
sss = c.GetAttrib("MyList")

(There are even fancier things you can to with casting functions in 
case you don't know what list name will be used and want to determine 
that programmatically at run time.  But that is far too advanced a topic.)

But I really prefer Peter's answer, since it is a little clearer 
(insofar as it relies a little less on deep understanding of E-Prime 
lists and attributes) and allows for more control and flexibility.

And please, as always do not take my word for any of this!  I insist 
that you to construct your own demonstration programs and test this 
for yourselves.

My apologies to all for not getting this right the first time, and 
for once again posting a lengthy explanation,
-- David McFarlane, Professional Faultfinder


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