Howdy, Stranger!

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

Supported by

[solved] Different ERP triggers for different conditions

edited November 2012 in OpenSesame

Hi There!

quick question about ERP triggers. If I want to send different triggers for different conditions in my experiment
(e.g. I have named the following variables in my loop item "Context" consisting of Whole, Half and Quarter and "Lateralization" consisting of Right and Left)
would the following inline script send the correct triggers?

E.g. "Whole left" will send trigger 11 and "Quarter Right" will send trigger 32

If self.get("Context") = Whole:
    p = 1
elif self.get("Context") = Half:
    p = 2
else:
    p = 3

If self.get("Lateralization") = Left:
    o = 1
else:
    o = 2

global io
trigger = po
port = 0x378
try:
    io.DlPortWritePortUchar(port, trigger)
except:
    print 'Failed to send trigger!'

Thanks in advance!

Michel

Comments

  • ITA

    We will come back to you as soon as possible.

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

  • edited November 2012

    Hi Michel!

    You could do this as follows:

    NOTE: edited in line with Lotje's comment below:

    if self.get("Context") == Whole:
        p = '1'
    elif self.get("Context") == Half:
        p = '2'
    else:
        p = '3'
    
    if self.get("Lateralization") == Left:
        o = '1'
    else:
        o = '2'
    
    strpo = p + o
    po = int(strpo)
    

    What the script does is saving your triggerparts as strings, then adding the strings for p and o together and finally reverting them to integers.

    Good luck!

    Edwin

  • edited 6:07PM

    Hi Edwin,

    thanks for the reply. Good call to save them as strings and reverting them to integers, I hadn't thought of that to get the 'po' part working.

    Unfortunatly, the script in total doesn't seem to work and gives me the following error:

    Python 2.6.6
    Type "help()", "copyright()", "credits()" or "license()" for more information.
    Type "modules()" for details about installed modules and version information.
    Use the "print [msg]" statement in inline_script items to print to this debug window.
    >>> 
    openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 512
    openexp._canvas.legacy.init_display(): enabling hardware surface
    openexp._canvas.legacy.init_display(): enabling double buffering
    openexp._canvas.legacy.init_display(): video mode ok
    experiment.init_log(): using 'C:/Documents and Settings/erp.users/Desktop/[PMQ]CNSWexp1/subject-0.csv' as logfile (ascii)
    experiment.run(): experiment started at Mon Nov 26 12:04:37 2012
    Traceback (most recent call last):
      File "libopensesame\inline_script.pyo", line 97, in prepare
      File "", line 1
        If self.get("Context") = Whole:
              ^
    SyntaxError: invalid syntax
    

    I guess he doesn't recognize the variable? Or I refer to it in the wrong way?

    greetings,

    Michel

  • NOTE: the answer was edited after being posted.

    Hi Michel,

    There are three problems with the if-then statements in your script:

    Firstly, note the following general rule:

    When assigning a value to a variable, use =, the assignment operator, like so:

     i = 5

    When comparing if two objects are equal, such as when comparing whether the variable Context has the value "Whole", use ==, the equal-to operator, like so:

    if i == 5:
    print "i is five"

    Secondly, you should indicate that the value 'whole' is a string, by putting the word into sinlge (') or double (") quotes.

    Thirdly, 'if' does not start with a capital (and neither do all other parts of control flow statements).

    Applied to your script, this becomes:

    if self.get("Context") == "Whole":
    p = '1'

    etc.

    I hope this helps,

    Best wishes,

    Lotje

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

  • edited 6:07PM

    Lol, I should've spotted that!

  • edited 6:07PM

    Thanks a lot!

    I should have seen that aswell. I should know basic python (although I'm just starting with it and have no previous programming experience).

    The script is working great now!

    Michel

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