When you're working with both squiffy code and JavaScript code in the same section or passage, one thing you have to always consider is that JavaScript always runs first. mrangel taught me a way to work around this. The below work:
squiffy.ui.processText("{@trueAttribute}")
squiffy.ui.processText("{@not falseAttribute}")
squiffy.ui.processText("{@attribute=123}")
squiffy.ui.processText("{@attribute2+=456}") //or -, *, /
squiffy.ui.processText("{@attribute=@attribute2}")
squiffy.ui.processText("{if attribute=@attribute2:{@theyreEqual}}")
squiffy.ui.processText("{if not falseAttribute:{@thatsNotTrue}}")
squiffy.ui.processText("{if @attribute<=579:{@itsLess}}")
But these don't work:
squiffy.ui.processText("{if @attribute<>122:{@Nope}}")
squiffy.ui.processText("{if attribute>=122:{@Nope}}")
Seriously, what gives?!
That's bizarre. This looks like a bug in processTextCommand_If
… but if the same problem crops up with {if …} blocks in normal text, I would really have expected it to be fixed by now.
Looking at the code for the if
text processor command, it looks like the operators it supports are:
=
- attribute equals value<
or <
- attribute is less than value<=
or <=
- attribute is less than or equal to value>
- attribute is greater than value>=
- attribute is greater than or equal to value<>
or <>
- attribute is not equal to value(It uses replace
to change <
to <
, and then compares it to a set of patterns which contain <
and >
)
To fix this, I think you can look in squiffy.template.js
for the line (line 454 on the version I have):
condition = condition.replace("<", "<");
and change to:
condition = condition.replace("<", "<").replace(">", ">");
Mrangel, you are a saint.
If I were a saint my name would be Simon, not Angel.
And I'd appreciate the compliments a lot more if the person giving it weren't a spambot.
(Though I'm glad I can help IFforClassroom and other real users)