okay, I started thinking about how to break down complex logic, and I was thinking this... seperate the action from the evaluation, for example
findTruth "q8","Q","greaterequal",9,"V",skipToQ8B
findTruth "q8","Q","lessequal",2,"V",skipToQ8A
Code: Select all
command findTruth pVal1 pVal1src pOperator pVal2 pVal2Src pHolder pOverwriteTruth
if pOverwriteTruth is not true then
put getVar(pHolder) into tCheck
if tCheck is true then exit findTruth
end if
put false into temp
if pVal1 is "current" then put field "qLabel" into pVal1 ---tossed this in to make logic reusable in questionnaire
if pVal1src is "S" then put wreckord["sein"][pVal1] into tX --sample data
if pVal1src is "Q" then put getCodes(pVal1) into tX --question data
if pVal1src is "V" then put getVar(pVal1) into tX --generated variable
if pVal2src is "S" then put wreckord["sein"][pVal2] into tY
if pVal2src is "Q" then put getCodes(pVal2) into tY
if pVal2src is "V" then put getVar(pVal2) into tY
if pVal2src is "K" then put pVal2 into tY --constant value
repeat for each item tCode in tX
switch pOperator
case empty
break
case "anytrue" --for generated vars that are booleans
if tX is true or tY is true then put true into temp
break
case "alltrue" --for generated vars that are booleans
if tX is true and tY is true then put true into temp
break
case "text" --specifically for sample vars
if tCode is tY then put true into temp
case "among" --specifically for mult response pVal2Src
if tCode is among the lines of tY then put true into temp
break
--none of the below cases will work if pVal2 is a multiple response question
case "equal"
if tCode = tY then put true into temp
break
case "notequal"
if tCode <> tY then put true into temp
break
case "greaterequal"
if tCode >= tY then put true into temp
break
case "lessequal"
if tCode <= tY then put true into temp
break
case "greater"
if tCode > tY then put true into temp
break
case "less"
if tCode < tY then put true into temp
break
end switch
if temp is true then exit repeat
end repeat
addVar pHolder,temp
end findTruth
command addVar pName pVal
put pVal into wreckord["data"][pName]
end addVar
function getVar pName
return wreckord["data"][pName]
end getVar
So running these 2 commands will net me two variables named skipToQ8B and skipToQ8A which will have a value of either true or false.
I can create seperate commands that will act if things are true.
am I over thinking this?