Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27~pre11 (Frisky Freud)
- # Sun Sep 30 14:49:15 2012 (posix)
- # <http://www.cogsci.nl/opensesame>
- set mouse_backend "legacy"
- set subject_parity "even"
- set response2 ""
- set height "768"
- set sound_buf_size "512"
- set font_italic "no"
- set custom_cursor "yes"
- set synth_backend "legacy"
- set title "Example for Sylvia"
- set coordinates "relative"
- set start "experiment"
- set sampler_backend "legacy"
- set font_family "mono"
- set foreground "white"
- set font_bold "no"
- set description "In this example it is checked whether the text input is an integer between 0 and 100."
- set background "black"
- set font_size "18"
- set keyboard_backend "legacy"
- set canvas_backend "legacy"
- set compensation "0"
- set subject_nr "0"
- set width "1024"
- define sketchpad warning_msg
- set duration "1000"
- set description "Displays stimuli"
- draw textline 0 0 "Please choose a number between 0 and 100 as text input." center=1 color=white font_family=mono font_size=18 font_italic=no font_bold=no show_if="always"
- define sequence experiment
- run warning_msg "never"
- run form_base "never"
- run inline_script "always"
- define inline_script inline_script
- ___run__
- # Make a list containing all allowed text inputs, that is,
- # integers between 0 and 100:
- # For documentation about the built-in Python function range(), see:
- # http://docs.python.org/library/functions.html#range
- allowed_list = range(0,101,1)
- # Keep showing the form as long as its incomplete.
- # For documentation about while loops in Python, see:
- # http://wiki.python.org/moin/WhileLoop
- while True:
- # Make a variable storing whether the form is completely filled
- # in on or not. The starting value is False. If one of the
- # 'checks' below is not met, its set to True:
- incomplete = False
- # Execute the prepared form_base:
- exp.items["form_base"].prepare()
- exp.items["form_base"].run()
- # Check whether the variable "response" is a number between 0 and 100,
- # that is, whether it is one of the allowed responses from the list
- # defined above:
- if not self.get("response") in allowed_list:
- incomplete = True
- # If incomplete is still False, break out of this while loop
- # and continue with the experiment.
- if not incomplete:
- break
- # If the form turns out to be incomplete, show a warning.
- else:
- exp.items["warning_msg"].prepare()
- exp.items["warning_msg"].run()
- # Next, the form_base will be executed again.
- # This continues as long as the form is incomplete.
- __end__
- set _prepare ""
- set description "Executes Python code"
- define form_base form_base
- set rows "1;1;1"
- set cols "1;1"
- set allow_empty "no"
- widget 0 0 2 1 label text="Indicate your confidence (0-100%)"
- widget 0 1 2 1 text_input var="response"
- widget 0 2 2 1 button text="Next"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement