[solved] Reading in stimuli list
Hello - I have a simple .txt file that contains a list of words that are also the names of associated .wav files and .bmp files. For example, the list contains "cat", "dog", etc., and in the same directory I have cat.wav, cat.bmp, dog.wav, dog.bmp, etc.
At different parts in my experiment I want to read in the list, shuffle it, and then choose one item to either (1) display the word in a sketchpad, (2) play the associated wav file in sampler, or (3) display the associated bmp in sketchpad. I've been trying to use this discussion as a model: http://forum.cogsci.nl/index.php?p=/discussion/469/solved-selective-sampling-with-a-ratio-help-please. Right now, before my sequence I have an inline script like the following:
path_list = exp.get_file("list1.txt") import numpy as np stimlist = np.loadtxt(path_list, dtype = str) import random random.shuffle(stimlist) global stimlist word = stimlist.pop() exp.set("word", word)
And then in the following step I have a sketchpad ("my_sketchpad") in which I'm trying to display [word]. But every time I run it, I get the error message: "Error: Runtime error Description: Variable 'word' is not set in item 'my_sketchpad'."
All the relevant files, including the experiment file itself, are in the same directory, and so I'm really banging my ahead against the wall here. Can anyone please tell me why it says the variable is not set? I tried putting in "global word" at the end and that didn't help either. Thank you in advance!