0 votes

I want to be able to do something like this, where I embed if statements under answers that check to see if certain conditions are met.

*question: Do you agree with this?
	Agree
		*if: sex = "Male"
		    		{reject_message}
		    		*quit
	Disagree
		*if: sex = "Female"
		    		{reject_message}
		    		*quit
	No Opinion
		{reject_message}
		*quit
	*save: beliefs
	*throwaway

It doesn't seem like this is possible... The code runs, but none of the reject conditions are getting triggered, even though they should be. Is it possible to do this? What's the easiest way to achieve something similar?

(I'm trying to avoid three big if statements)

by (480 points)
edited by

2 Answers

+2 votes
Best answer

I wonder if that was a temporary glitch of GT. I have given a value to the variables and put something else after the question:

>> sex = "Male"
>> reject_message = "bleh"

*question: Do you agree with this?
	Agree
		*if: sex = "Male"
			{reject_message}
			*quit
	Disagree
		*if: sex = "Female"
			{reject_message}
			*quit
	No Opinion
		{reject_message}
		*quit
	*save: beliefs
	*throwaway
	
Done

When I click on Agree, the output is bleh, when I click on Disagree the output is Done and with No Opinion, the output is bleh as well. The program is here: https://www.guidedtrack.com/programs/18714/edit

by (3.6k points)
selected by

Hmm, yeah. I think it might have been a temporary glitch (perhaps due to Split mode?) I'm no longer getting the error, and the error in the console was a bit cryptic (it didn't list a line number where the error was occurring).

Thanks for checking!

0 votes

As Belén said, this should work. Are you sure the sex variable is defined when the *ifs run?

by (1.8k points)
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users