IUtilizeScripts Posted April 21, 2014 Share Posted April 21, 2014 (edited) Hello, I'm having difficulty understanding how to evaluate as String as a Boolean expression in an IF statement. Will one of you please assist me in accomplishing this? Here is the code I have so far: #include <Array.au3> Local $aTest[5] = [1,2,3,4,5] Local $iLimit = 3 Local $sCriteria = "$avArray[$i] >" & $iLimit _ArrayDisplay($aTest) $aTest = CondenseArray($aTest, $sCriteria) _ArrayDisplay($aTest) Func CondenseArray($avArray, $sCriteria) Local $Keep[UBound($avArray)] Local $HitNo = 0 For $i = 0 to Ubound($avArray) - 1 Step 1 If $sCriteria Then $Keep[$HitNo] = $i $HitNo = $HitNo + 1 EndIf Next ReDim $Keep[$HitNo] Local $avRevisedArray[UBound($Keep)] If UBound($avArray, 0) = 1 Then For $row = 0 to Ubound($Keep, 1) - 1 $avRevisedArray[$row] = $avArray[$Keep[$row]] Next EndIf Return $avRevisedArray EndFunc Thank you. Edited April 21, 2014 by IUtilizeScripts Link to comment Share on other sites More sharing options...
FireFox Posted April 21, 2014 Share Posted April 21, 2014 Hi, You're talking about evaluation, but I don't see the Eval function anywhere. Br, FireFox. Link to comment Share on other sites More sharing options...
Solution IUtilizeScripts Posted April 21, 2014 Author Solution Share Posted April 21, 2014 (edited) Hi, You're talking about evaluation, but I don't see the Eval function anywhere. Br, FireFox. Thanks for the help! I didn't know that the Eval or Execute functions existed. The solution was the Execute function: #include <Array.au3> Local $aTest[5] = [1,2,3,4,5] Local $iLimit = 3 Local $sCriteria = "$avArray[$i] >" & $iLimit _ArrayDisplay($aTest) $aTest = CondenseArray($aTest, $sCriteria) _ArrayDisplay($aTest) Func CondenseArray($avArray, $sCriteria) Local $Keep[UBound($avArray)] Local $HitNo = 0 For $i = 0 to Ubound($avArray) - 1 Step 1 If Execute($sCriteria) Then $Keep[$HitNo] = $i $HitNo = $HitNo + 1 EndIf Next ReDim $Keep[$HitNo] Local $avRevisedArray[UBound($Keep)] If UBound($avArray, 0) = 1 Then For $row = 0 to Ubound($Keep, 1) - 1 $avRevisedArray[$row] = $avArray[$Keep[$row]] Next EndIf Return $avRevisedArray EndFunc Edited April 21, 2014 by IUtilizeScripts Link to comment Share on other sites More sharing options...
FireFox Posted April 21, 2014 Share Posted April 21, 2014 Right Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now