Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketchpad on loop variable "duration" not set at first iteration #772

Closed
rChahine opened this issue Nov 11, 2021 · 1 comment
Closed

Sketchpad on loop variable "duration" not set at first iteration #772

rChahine opened this issue Nov 11, 2021 · 1 comment

Comments

@rChahine
Copy link

Hi

# system information
API: 2.1
OpenSesame: 3.3.9b1
Platform: posix

I'm trying to run a loop that contains a keyboard which updates a global variable named "Ta".

"Ta" has been initialized at 0 before the loop.
githubissue

At the first iteration, "Ta" has no effect on the duration of Sketchpad "Blanck_part3_2", then, since the second iteration, the correct duration is set.

We know that the duration of "Blanck_part3_2" at the first iteration is the initial value despite the incrementation of "Ta"

Here's the code for handling keyboard input and update "Ta" variable:

my_keyboard = Keyboard(keylist=['S', 'L', 's', 's'], timeout=500)

start_time = clock.time()
_, end_time = my_keyboard.get_key()

var.Ta += end_time - start_time  # end_tme - start_time = temps d'execution
print(f"itération no: {var.count_2} | Ta -> {var.Ta}")

Here the output (that works as expected)

itération no: 0 | Ta -> 234.66181755065918  # Blanck_part3_2 duration is not set
itération no: 1 | Ta -> 298.0988025665283  # Blanck_part3_2 duration is set correctly
itération no: 2 | Ta -> 319.02170181274414 # Blanck_part3_2 duration is set correctly
itération no: 3 | Ta -> 331.1147689819336 # Blanck_part3_2 duration is set correctly

Here's how we set duration to "Blanck_part3_2" sketchpad
python set duration "[Ta]"

Do you have any idea what's wrong ?

thanks

@smathot
Copy link
Collaborator

smathot commented Nov 12, 2021

I suspect that this happens because the Blanck_part3_2 prepared before the Ta variable is set, as explained in this section of the documentation:

If that's not it, would you remind reposting this question on the support forum? I'm closing the issue here because it's not an issue as such, but rather a question related to usage.

@smathot smathot closed this as completed Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants