Howdy, Stranger!

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

Supported by

Passing variables to search array

Hello!

I am helping a friend and am looking for a way to pass a GUI experimental value into an inline script and then search an array for that variable in order to access associated sound files. I am not sure I am passing the variable correctly, but I also am not sure if the index feature works in OpenSesame?

My array stimlist would contain target_word1, word1sound1, word1sound2, word1sound3, word2, word2sound1, word2sound2,word2sound3 etc. My goal would be to have the GUI loop randomly select the target_word, and then I use the inline script to randomly select one of the 3 sound files to play while the target_word is displayed using the sketchpad. I thought to use the index feature of python to identify what place in the array target_word can be found, then generate a random number 1-3 to add to the place in the array to call the sound file. Of course, if someone has a more elegant way to achieve this, I am also all ears. I am not super familiar with Python and it's been 10 years since I was actively programming (in Java and Perl).

Comments

  • Not sure whether I perfectly understand what you want to accomplish, but if it to generate a path to a sound file based on a randomly generated target word, I highly recommend using intuitive file names. For example, if the target word variables are called target_word_X, you can name all the sound files target_word_X_sound, so that you can simply retrieve the target word, add the sound part and load the sound.

    Does that make sense?

    Eduard

    Buy Me A Coffee

  • edited November 2018

    I need to generate a path to a sound file, but it is ALSO a randomly selected sound file.

    So if my Primary list is
    Sun
    Moon
    Star

    I need to randomly select one of those 3 words in the Sound list. THEN each word has 3 sound files associated with it
    Sun (Big, ball, yellow)
    Moon (Circle, white, small)
    Star (dark, shine, tiny)

    The program needs to run through ALL of the primary list, but only ONE of each of the Sound files are played.

    So one participant will be presented with
    Sun - Big
    Star - Dark
    Moon - Circle

    And another might be presented with
    Star - Tiny
    Moon - White
    Sun - Ball

    So every primary needs to be listed, but only 1 randomly selected sound.

    So, what I thought was to have a stimuli list stored as an array such as
    Sun
    Big.wav
    Ball.wav
    yellow.wav
    Moon
    circle.wav
    white.wav
    small.wav
    Star
    dark.wav
    shine.wav
    tiny.wave

    And then if the program selects "Moon" I search the list for "Moon" using the index which would return an integer 4 (since Moon is in position 4). Then, I random 1-3 to get which of the 3 sound files to pull. I could then add Moon's position (4) to the random option (2) and get 6 - so I will then access List[6] and it will pull the sound file name white.wav which I then load into Sampler to play the sound while the target (moon) is displayed.

  • Actually, I could probably do that.

    But I still can't pass the target_word variable from the GUI. The help file is very unclear about how the var.get works - is var the actual file name? Is it a module? I really don't understand.

    I think the rest of my code will work for it, so thanks for the way more elegant idea. I have no idea why I didn't think of concatenating the string before. Probably because when I originally designed it, I was just working off what my friend gave me, and was making the program fit her stuff rather than adjusting her stuff to make the program easier.

  • Hi,

    You don't have to get the variable. You can simple use is it by prepending the var.. So if in your loop table you have the variable target_word, you can access its value by writing var.target_word in an inline_script. Does that work?

    Eduard

    Buy Me A Coffee

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