Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Global variable

edited December 2013 in OpenSesame

Hi there, I'm a bit of a noob with Opensesame so this question might sound totally ridiculous.
So, I need to define a variable which can be used by multiple items (sketch pad, keyboard response, logger, etc.). I know such a variable can be defined with exp.set via inline script, the problem is that I don't know how to change the value of the variable during the experiment.

For example, I want the variable value to change depending on the keyboard response, and then for the sketch pad to use that value in displaying new stimuli.

So in short, I need a variable which can be used and changed by any item.

Comments

  • edited 11:33PM

    Hi,

    If you want a given variable to have a different value for, for example, every trial, it's more convenient to define this variable via a loop item.

    Did you already read this page?

    If this doesn't answer your question, could you please explain what kind of experiment you're exactly trying to build?

    Cheers,

    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited 11:33PM

    Yeah, I know about defining variables within a loop. The problem is I need a "free" variable, accessible by multiple items.
    The experiment is meant to use the adjustment method in psychophysics.
    I'd use a sketch pad item, keyboard response item and a repeat cycle item.
    The sketch pad would present an ellipse and the participant would press left or right keys to adjust it in order to make it look as much as possible like a perfect circle, once they're satisfied they would press enter and the repeat cycle would stop.
    I know how to make it work but in order to implement my solution I need a variable not set and changed by the loop, a free global variable that would change depending on the participants response. It would be simple to do if that kind of variable is possible within OpenSesame.
    Define it at the beginning of the experiment and manipulate it later, is it possible or not?

  • edited December 2013

    That's possible with a tiny bit of inline scripting. Add the following to either phase of an inline_script at the start of your experiment, somewhere before your loop:

    # define the starting value
    exp.set("my_var", 0)
    

    Then, in your loop, manipulate the variable as you please by pasting the following in an inline_script's Run phase:

    # get current state
    current = exp.get("my_var")
    
    # do some adjustment here, e.g.
    if exp.get("correct"):
        current += 1
    else:
        current -= 1
    
    # then set the variable again, which updates it to the OpenSesame environment
    exp.set("my_var", current)
    
  • Hi, I have a similar problem. Depending on a value in a question asked before the actual loop I want to run different versions of an experiment. I used the above code to set my variable and update it and it is shown in the variable editor/overview with chosen values, yet I am told that this variable does not exist and the experiments stops. I place one inline script right at the beginning to set the variable and one right after the question were people give the answer upon which the experimental version is decided. I uploaded the experiment and would appreciate any hints - best Miriam


  • Fixed it by adding a missing letter - sorry. Now everything is perfect

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games