Conditional statements and captions


Conditional statements and captions

Author
Message
psych101
psych101
Associate Member
Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)

Group: Forum Members
Posts: 14, Visits: 73
Hello,

I would appreciate any help with a couple of questions about changing the presentation on the screen based on conditional statements.

First, how could I conditionally change the colour of a caption, if a certain value (trialtype == 1) is met?

Under surveypages, I tried the following:
if (values.trialtype == 1) {
values.player_c = "you"; 
caption.c.txcolor = red}

This did not work as it did for the text in the forum response here: https://www.millisecond.com/forums/Topic16701.aspx

Is there any way to get around this?

In addition, I want to create a caption on the surveypage that only occurs if trialtype ==1 is met. Would I approach this the same way as I did above?

Thank you

Dave
Dave
Supreme Being
Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)Supreme Being (665K reputation)

Group: Administrators
Posts: 9.7K, Visits: 45K
psych101 - 8/7/2019
Hello,

I would appreciate any help with a couple of questions about changing the presentation on the screen based on conditional statements.

First, how could I conditionally change the colour of a caption, if a certain value (trialtype == 1) is met?

Under surveypages, I tried the following:
if (values.trialtype == 1) {
values.player_c = "you"; 
caption.c.txcolor = red}

This did not work as it did for the text in the forum response here: https://www.millisecond.com/forums/Topic16701.aspx

Is there any way to get around this?

In addition, I want to create a caption on the surveypage that only occurs if trialtype ==1 is met. Would I approach this the same way as I did above?

Thank you

Changing the color is not possible with captions. To make a caption appear or disappear conditionally, manipulate its position.

<caption mycaption>
/ caption = "Bla"
/ position = (values.x, values.y)
</caption>

<list trialtypes>
/ items = (1,1,0,0)
</list>

<values>
/ trialtype = 0
/ x = -10%
/ y = -10%
</values>

<surveypage mypage>
/ ontrialbegin = [
values.trialtype = list.trialtypes.nextvalue;
]
/ ontrialbegin = [
if (values.trialtype == 1) {
values.x = 40%;
values.y = 10%;
} else {
values.x = -10%;
values.y = -10%;
}
]
/ questions = [1=mycaption]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<block myblock>
/ trials = [1-4 = mypage]
</block>

Theoretically, you can use the same position-trick above to get your color-change effect. I.e. if trialtype is 1, move a caption with /txcolor = red on-screen (move it off-screen otherwise), if trialtype is not 1, move a different caption with /txcolor = black on-screen (move it off otherwise).

Edited
2 Weeks Ago by Dave
psych101
psych101
Associate Member
Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)Associate Member (220 reputation)

Group: Forum Members
Posts: 14, Visits: 73
Thanks, Dave! This worked for both the cases I needed help with. 
GO


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....






Millisecond Forums


Search