Randomization problem

Adam Osth adamosth at gmail.com
Mon May 18 21:09:50 UTC 2009


Ah! Works perfectly now.

Thanks so much for your help!

-Adam

On Mon, May 18, 2009 at 3:46 PM, David McFarlane <mcfarla9 at msu.edu> wrote:

>
> D'oh!  Of course, why didn't I see that!  "Picture:drawno" is treated
> as a literal string, it does not evaluate the variable.  To do that
> you need to construct a string containing the value of the
> variable.  So please try something like the following:
>
> TestList.setAttrib counter, "Item", c.GetAttrib("Picture:" & drawno)
>
> -- David McFarlane, Professional Faultfinder
>
>
> At 5/18/2009 03:27 PM Monday, you wrote:
> >Ah, I had never thought of that.
> >
> >However, I just tested it with fixed defined numbers (ie:
> >c.GetAttrib("Picture:3")) and it seems to index the correct files
> >just fine. It's only when I use a variable in the colon notation
> >that it has problems (ie: c.GetAttrib("Picture:y")) and defaults to zero.
> >
> >Are there other ways of doing this randomization procedure? It's a
> >little bit sophisticated, which is why I'm using inline code. The
> >program needs to randomly select one picture from 8 pictures in a
> >list that are all presented in random sequence, store that filename
> >and write it to another list for later presentation.
> >
> >Adam
> >
> >On Mon, May 18, 2009 at 3:17 PM, David McFarlane
> ><<mailto:mcfarla9 at msu.edu>mcfarla9 at msu.edu> wrote:
> >
> >Adam,
> >
> >Wow, I don't know offhand if that syntax works.  It looks like you
> >are trying to use "colon syntax", and I don't know if you can use
> >that with the Context.GetAttrib() method, that may work only with the
> >List.GetAttrrib() method (e.g., colon syntax has to know which List
> >has the attribute "Picture").  I would have to make some demo
> >programs and look at the generated code to explore this further, but
> >I will leave that to you.
> >
> >-- David McFarlane, Professional Faultfinder
> >
> >
> > >I just realized when you sent this that it might be due to how the
> > >random number is applied.
> > >
> > >I have the randomization code to select a picture for presentation,
> > >so I did this:
> > >TestList.setAttrib counter, "Item", c.GetAttrib("Picture:drawno")
> > >
> > >...in which one of the 8 files in the attribute "Picture" on another
> > >list is randomly selected.
> > >
> > >Is it defaulting to zero because this isn't syntactically valid?
> > >
> > >Adam
> > >
> > >On Mon, May 18, 2009 at 2:59 PM, David McFarlane
> > ><<mailto:mcfarla9 at msu.edu><mailto:mcfarla9 at msu.edu>mcfarla9 at msu.edu>
> wrote:
> > >
> > >Adam,
> > >
> > >Hmm, that bit of code works perfectly for me.  I suspect the problem
> > >lies somewhere else in the script.  Just to be clear, try the
> > >following and see what happens:
> > >
> > >Dim drawno As Integer
> > >Dim i as Integer
> > >For i = 1 to 8
> > >     drawno = Random(0, 7)
> > >     MsgBox drawno
> > >Next i
> > >
> > >-- David McFarlane, Professional Faultfinder
> > >
> > >
> > > >I'm having a little problem with randomization code in Ebasic. I
> > > >have this code:
> > > >
> > > >Dim drawno As Integer
> > > >drawno = Random(0, 7)
> > > >
> > > >...and yet, drawno is initialized to '0' every time. This code is
> > > >used for 8 repetitions in the program, and each time "0" comes up.
> > > >Even with "Randomize" in front, the same thing happens.
> > > >
> > > >Is there something I'm doing wrong?
> > > >
> > > >Adam
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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/20090518/5e410f84/attachment.htm>


More information about the Eprime mailing list