+1
Answered

if statement not working in android

jenifercmartin 7 years ago updated by icahill (Administrator) 7 years ago 3
I have a couple of if statements in an app that work perfectly for iOS but are not working at all in android. The app just completely ignores the direction. Any idea why?
Can you confirm that your variables are saving the correct values? Perhaps Android returns conditions such as NaN as blank instead.
I put an alert to check what values are returning. The if statement is not firing, even when i can confirm that var:final is returning NaN or Infinity. Another function is dependent upon these if statements firing, which is why I care so much about these...
I have put a ticket in for this. The logs indicate that NaN and Infinity coming from an eval don't pop the if statements in Android.

As a workaround I used your var:final1 and added text like this and the if statement seems to fire now.

<assign property="var:final" value="[eval:['[var:gradegoal]'-['[var:gradecurr]'*[1-'[var:gradefinalweight]']]]/'[var:gradefinalweight]']"></assign>
<assign property="var:final1" value="[var:final]nan"/>


See action below:


<action name="calculate">
<sync>
<assign property="var:final" value="[eval:['[var:gradegoal]'-['[var:gradecurr]'*[1-'[var:gradefinalweight]']]]/'[var:gradefinalweight]']"></assign>
<assign property="var:final1" value="[var:final]nan"/>
<assign property="var:social" value="I need to score [var:final1]% on my [var:subjectsetting] final. Find out what you need to get on your finals. Download Gradiator. It's free. https://itunes.apple.com/us/app/gradiator/id667507377?mt=8" />
<assign property="object:CALCULATE.background" value="#4b4b4b"/>
<set onclickup="reset-calculate"/>
<alert message="var:final equals [var:final]"/>
<if lhs="[var:final1]" operator="e" rhs="NaNnan">
<alert message="NaN"/>
<assign property="object:CALCULATE_MSG.text" value="Oops. Try again."/>
<assign property="object:CALCULATE.background" value="#c0392b"/>
<alpha value="1" target="SUBJECT1"/>
<alpha value="0" target="RESULTCNTR"/>
</if>
<if lhs="[var:final1]" operator="e" rhs="Infinitynan">
<alert message="Infinity"/>
<assign property="object:CALCULATE_MSG.text" value="Oops. Try again."/>
<assign property="object:CALCULATE.background" value="#c0392b"/>
<alpha value="1" target="SUBJECT1"/>
<alpha value="0" target="RESULTCNTR"/>
</if>
<if lhs="[var:final1]" operator="ne" rhs="NaNnan">
<if lhs="[var:final1]" operator="ne" rhs="Infinitynan">
<set onclickup="clear-calculator" target="TOOLBAR_IMG2"/>
<alpha value="0" target="SUBJECT1"/>
<alpha value="1" target="RESULTCNTR"/>
<assign property="object:RESULT_MSG.text" value="GOAL for FINAL"/>
<assign property="object:RESULT_MSG1.text" value="[var:final]%"/>
<assign property="var:socialpost" value="[var:social]" />
<play action="save-study"/>
<assign property="object:CALCULATE_MSG.text" value="ADJUST ENTRIES"/>
<if lhs="[preferences:showtip1]" operator="ne" rhs="0">
<translate target="TIP_PANEL_1" ypos="28%"/>
<assign property="preferences:showtip1" value="0" />
<assign property="preferences:showtip2" value="1" />
</if>
</if>
</if>
</sync>
</action>