<div>something like this?</div><div><br></div>for m = 1 to 4<br><br>triallist.SetAttrib m, "restid" & m, randomlist(randompos(m-1))<br><br><div>next m<br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 3:52 PM, liwenna <span dir="ltr"><<a href="mailto:liwenna@gmail.com">liwenna@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Short question:<br>
In the piece of code below: how do I implement a variable that<br>
replaces the digits 1-3 in the attribute names 'restid1' - 'restid3'<br>
so that I can shorter the code to a single line (using an additional<br>
'for 0 to 2' variable for the (randompos(x)) part) ?<br>
<br>
**************************************<br>
for m = 1 to 4<br>
<br>
triallist.SetAttrib m, "restid1", randomlist(randompos(0))<br>
triallist.SetAttrib m, "restid2", randomlist(randompos(1))<br>
triallist.SetAttrib m, "restid3", randomlist(randompos(2))<br>
<br>
randomizearray randompos<br>
<br>
next m<br>
***************************************<br>
<br>
Long explanation:<br>
Ok.... So... I have this habit of writing enormous inlines because I<br>
am generally to lazy or not in the mood to figure out/learn how to<br>
shorten them.... I decided that I am gonna break this habit and have<br>
choosen a nice litle experiment to do this with. However: I am stuck<br>
now. My hope is that someone here knows off hand what lines I need and<br>
is able to drop me a line.<br>
<br>
In the final experiment each display holds 16 positions which will be<br>
filled with one targetstimulus and 15 distractorstimuli. There are 16<br>
possible targetstimuli which will each have to appear in one of the 16<br>
possible positions (a 4x4 grid, 16 locations x16 targetstimuli = 256<br>
trials). The identity of the targetstimulus decides which 15 stimuli<br>
should be used as distractorstimuli and I like to have the location of<br>
each of the distractorstimuli randomized... Unfortunately this means<br>
that for each trial there are 15! possible arrangements of the<br>
distractorstimuli (1 307 674 368 000). I don't like<br>
pseudorandomizations that well so I took up the challenge and actually<br>
got quite far so far. For obvious reasons I am working the whole thing<br>
out with a smaller number of positions: 4 (2x2 grid).<br>
<br>
This is what I got now: for target ID 1 a list with the 15<br>
distractorstimuli for this target is loaded from a textfile into an<br>
array and randomized. A second array holds the numbers 1-15 which<br>
corresponds with locations 1-15. For each level of the triallist (m)<br>
the randomized distractorstimuli are randomly loaded into attributes<br>
called "restid1" up to "restid3" (4 locations, 1 holds the target).<br>
When a level is filled, the randompos array is rerandomized so that<br>
for the next level each distractorstimulus is loaded into a different<br>
restid-attribute. The piece of code shown below deals with the first 4<br>
levels (target ID 1), the code will have to repeat for the next 4<br>
levels but then load id2restids.txt instead (containing<br>
distractorstimuli for target ID 2), etc etc. As you can see this<br>
inline will still become rather bulky so here's the question again:<br>
can I shorten the 3 lines that fill the triallist-levels to 1 line by<br>
using another 'for 1 to 3' attribute (one of those mysterious %_ & #<br>
perhaps?) that can actually be used IN an attribute name?<br>
<br>
***********************************************<br>
for m = 1 to 4<br>
<br>
Open "id1restids.txt" For Input As #1<br>
For n = 0 To 2<br>
Input #1, randomlist(n)<br>
Next n<br>
Close #1<br>
<br>
randomizearray randomlist<br>
<br>
for q = 0 to 2<br>
randompos(q) = q<br>
next q<br>
<br>
randomizearray randompos<br>
<br>
triallist.SetAttrib m, "restid1", randomlist(randompos(0))<br>
triallist.SetAttrib m, "restid2", randomlist(randompos(1))<br>
triallist.SetAttrib m, "restid3", randomlist(randompos(2))<br>
<br>
randomizearray randompos<br>
<br>
next m<br>
*******************************************<br>
<br>
<br>
I've checked the guides, checked the e-primer, searching all over the<br>
place for a piece of code that I could steal the trick from, but to no<br>
avail so far. What certainly doesn't help is that I so far never quite<br>
got the deal with the & % _ crf things.... (that's probably<br>
embarrassing but true :p )<br>
<br>
I hope someone knows a nice solution for me.<br>
<br>
Best regards,<br>
<br>
liw<br>
<br>
<br>
</blockquote></div><br></div>
<br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups "E-Prime" group. <br> To post to this group, send email to e-prime@googlegroups.com <br> To unsubscribe from this group, send email to e-prime+unsubscribe@googlegroups.com <br> For more options, visit this group at http://groups.google.com/group/e-prime?hl=en<br>
-~----------~----~----~----~------~----~------~--~---<br>
<br>