Doug,

You are looking at the function declaration, which says that the function
must be called with an argument. To simplify things, you might create a
function called PrintPlus:


define PrintPlus(a,b)
{
  Print(a+b)
}

When this function is used, you might do:

PrintPlus(1,3)

or:

x <- 1
y <- 4
PrintPlus(x,y)

When trial is run, whatever was passed as the argument will get bound to
the variables a and b, even if they were numbers outside, and even if they
were variables that had different names.  In general, x and y would not be
accessible within the function, except through a and b.

In the Trial case, stimpairs is what the argument is called within the
function.  The function is called with some other variable name, but the
same value is accessible inside via the stimpairs variable name.

Best,
Shane

> Hello All,
>
> A question relating to:
> First off, I am a non-programmer, noob, whatever. I am attempting to adapt
> a PEBL battery program (dspan.pbl) for my own experiment and am a little
> confused at variable declaration and passing of arguments in PEBL. Assume
> you are talking to a pre-K student about how computers work, and you'll be
> communicating on my level [?] Anyhow, I would sincerely appreciate any
> guidance that is shared...
>
> What is currently burning a small hole in my brain is a function argument
> that doesn't seem to relate to any declared variables elsewhere in the
> program.
>
> Below is a snippet of code that works, but I don't understand HOW it does
> so. The problem for me in this user-defined function is the word
> "stimpairs" - not defined anywhere else. How does the program "know" what
> value is represented by this argument? Clearly it has been used as an
> argument, processed, and then assigned to a new variable (like "stim",
> "length", and "string" in the code below).
>
> What gives???
>
> Thanks for help and advice!
>
>
> define Trial(stimpairs)
> {
>
>   stim <- First(Transpose(stimpairs))
>   length <- Length(stimpairs)
>   string <- ListToString(stimpairs)
>   dummy  <- Repeat("_",length)
>   responselist   <- []
>
>   gStimLabel.text <- "Length " + length
>   Show(gStimLabel)
>
>   Draw()
>   if(gUseAudio)
>    {
>      PlayForeground(gReady)
>    }
>   Wait(800)
>   Hide(gStimLabel)
>   Draw()
>   Show(gStimLabel)
>
>   Wait(1000)
>
>   loop(x,stimpairs)
>   {
>     digit <- First(x)
>     sound <-Nth(x,2)
>
>     FilePrint_(gFileOut,digit)
>     gStimLabel.text <- digit
>     Draw()
>     t1 <- GetTime()
>     if(gUseAudio){PlayForeground(sound)}
>     t2 <- GetTime()
>     Wait(gISI - (t2-t1))
>   }
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
> Pebl-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pebl-list
>



------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Pebl-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pebl-list

Reply via email to