Hello,
I am having a little dumb problem which I cannot solve by myself. Could sb look over it?
I start with two arrays:
<<set $sequenceMap to [
["x", "x", "x", "16", "9"],
["15", "x", "x", "3", "11"],
["8", "5", "x", "12", "x"],
["6", "4", "2", "13", "x"],
["1", "10", "7", "14", "x"]>>
<<set $itemCounter to [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]>>
Now this widget should iterate through $sequenceMap and put link-macro for every “non-x” value and check, if the links are clicked in correct sequence (1,2,3,…):
<<widget "generateClickArray">>\
<<for _i to 0; _i lt $sequenceMap.length; _i++>>\
<<for _j to 0; _j lt $sequenceMap[_i].length; _j++>>\
<<set _linkText to $sequenceMap[_i][_j]>>\
<<if $sequenceMap[_i][_j] neq "x">>\
<<link _linkText>>\
<<if _linkText eq $itemCounter[0]>>
<<run UI.alert("Click!")>>\
<<set $itemCounter.deleteAt(0)>>
<<else>>
<<run UI.alert("Wrong!")>>\
<</if>>
<</link>>\
<</if>>\
<</for>>\
<br/>
<</for>>\
<</widget>>
Link-macros are shown correctly, but widget always alerts “wrong”. But when I replace inner < if> macro with e.g. <<run UI.alert( _linkText)>>
it alerts “1” for link “1”, which equals $itemCounter[0], no?
I am sure there is something very obvious I must be missing…