how to... make a 'for 0 to x' variable that can insert digits IN an attribute name?
ben robinson
baltimore.ben at gmail.com
Wed Nov 4 21:10:12 UTC 2009
something like this?
for m = 1 to 4
triallist.SetAttrib m, "restid" & m, randomlist(randompos(m-1))
next m
On Wed, Nov 4, 2009 at 3:52 PM, liwenna <liwenna at gmail.com> wrote:
>
> Short question:
> In the piece of code below: how do I implement a variable that
> replaces the digits 1-3 in the attribute names 'restid1' - 'restid3'
> so that I can shorter the code to a single line (using an additional
> 'for 0 to 2' variable for the (randompos(x)) part) ?
>
> **************************************
> for m = 1 to 4
>
> triallist.SetAttrib m, "restid1", randomlist(randompos(0))
> triallist.SetAttrib m, "restid2", randomlist(randompos(1))
> triallist.SetAttrib m, "restid3", randomlist(randompos(2))
>
> randomizearray randompos
>
> next m
> ***************************************
>
> Long explanation:
> Ok.... So... I have this habit of writing enormous inlines because I
> am generally to lazy or not in the mood to figure out/learn how to
> shorten them.... I decided that I am gonna break this habit and have
> choosen a nice litle experiment to do this with. However: I am stuck
> now. My hope is that someone here knows off hand what lines I need and
> is able to drop me a line.
>
> In the final experiment each display holds 16 positions which will be
> filled with one targetstimulus and 15 distractorstimuli. There are 16
> possible targetstimuli which will each have to appear in one of the 16
> possible positions (a 4x4 grid, 16 locations x16 targetstimuli = 256
> trials). The identity of the targetstimulus decides which 15 stimuli
> should be used as distractorstimuli and I like to have the location of
> each of the distractorstimuli randomized... Unfortunately this means
> that for each trial there are 15! possible arrangements of the
> distractorstimuli (1 307 674 368 000). I don't like
> pseudorandomizations that well so I took up the challenge and actually
> got quite far so far. For obvious reasons I am working the whole thing
> out with a smaller number of positions: 4 (2x2 grid).
>
> This is what I got now: for target ID 1 a list with the 15
> distractorstimuli for this target is loaded from a textfile into an
> array and randomized. A second array holds the numbers 1-15 which
> corresponds with locations 1-15. For each level of the triallist (m)
> the randomized distractorstimuli are randomly loaded into attributes
> called "restid1" up to "restid3" (4 locations, 1 holds the target).
> When a level is filled, the randompos array is rerandomized so that
> for the next level each distractorstimulus is loaded into a different
> restid-attribute. The piece of code shown below deals with the first 4
> levels (target ID 1), the code will have to repeat for the next 4
> levels but then load id2restids.txt instead (containing
> distractorstimuli for target ID 2), etc etc. As you can see this
> inline will still become rather bulky so here's the question again:
> can I shorten the 3 lines that fill the triallist-levels to 1 line by
> using another 'for 1 to 3' attribute (one of those mysterious %_ & #
> perhaps?) that can actually be used IN an attribute name?
>
> ***********************************************
> for m = 1 to 4
>
> Open "id1restids.txt" For Input As #1
> For n = 0 To 2
> Input #1, randomlist(n)
> Next n
> Close #1
>
> randomizearray randomlist
>
> for q = 0 to 2
> randompos(q) = q
> next q
>
> randomizearray randompos
>
> triallist.SetAttrib m, "restid1", randomlist(randompos(0))
> triallist.SetAttrib m, "restid2", randomlist(randompos(1))
> triallist.SetAttrib m, "restid3", randomlist(randompos(2))
>
> randomizearray randompos
>
> next m
> *******************************************
>
>
> I've checked the guides, checked the e-primer, searching all over the
> place for a piece of code that I could steal the trick from, but to no
> avail so far. What certainly doesn't help is that I so far never quite
> got the deal with the & % _ crf things.... (that's probably
> embarrassing but true :p )
>
> I hope someone knows a nice solution for me.
>
> Best regards,
>
> liw
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20091104/e04a44bd/attachment.htm>
More information about the Eprime
mailing list