Sign in to follow this  
Followers 0
IUtilizeScripts

Using a String as Expression

4 posts in this topic

#1 ·  Posted (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 by IUtilizeScripts

Share this post


Link to post
Share on other sites



Hi,

You're talking about evaluation, but I don't see the Eval function anywhere.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by IUtilizeScripts

Share this post


Link to post
Share on other sites

Right :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0