Jump to content
Sign in to follow this  
blkshadow82

Return Row of _Arraysearch

Recommended Posts

blkshadow82

I am not exactly sure if I am approaching this correctly but here it is...

 

I have a table like this like this which I write to an array:

 

Column 1     Column 2

03/15/2012   TOT-TRF 

12/22/2011   TOT-TRF  

04/28/2011   TOT-TRF   

02/13/2007   CON-POS  

11/09/1998   TOT-CNV 

07/21/1998   TOT-CNV 

01/07/1998   TOT-CNV

 

I was using arraysearch to find "TOT-TRF" Which I was able to do successfully... but need to check the date in column 1 to see if it is after 2010 and if so it will trigger an action. I was thinking of a few different methods but not sure which is the best way to approach it.  I know if I could get the row that "TOT-TRF" is in then I could check the first column to see if it is greater than 2010.  To try to prevent any confusion I wont go into the other methods I had in mind unless it comes to that point and no one can help with what I have provided.

 

Not sure how helpful this will be but here is some of the code

$oEventgTable               = _IETableGetCollection($oPhObj2, 3)
$oEventgTable2              = _IETableWriteToArray($oEventgTable, True)
_arraydisplay($oEventgTable2)

$DateoD = _ArraySearch($oEventgTable2, "TOT-TRF",0,0,0,0,1,1)
msgbox(0,"",$DateoD)
if not @error Then
   $p11 = 1
   Else
   $p11 = 0
EndIf
I have to check a lot of these tables so I am trying to do this the quickest way possible.  Thanks ahead of time for any suggestions! Edited by blkshadow82

Share this post


Link to post
Share on other sites
FireFox

Hi,

Don't use the _ArraySearch function, it's limited to search in one column.

Make your own search like this :

;... _IE* functions here.
 
Local $iFoundIndex = -1
 
For $i = 0 To UBound($oEventgTable2) -1
    If $oEventgTable2[$i][1] <> "TOT-TRF" Then ContinueLoop
 
    ;we found TOT-TRF, now check the year if upper than 2010 (after 2010??)
    If Number(StringRight($oEventgTable2[$i][0], 4)) > 2010 Then
        $iFoundIndex = $i
        ExitLoop
    EndIf
Next
 
If $iFoundIndex > -1 Then
    ConsoleWrite("Record found at the index: " & $i & @CrLf)
EndIf

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
blkshadow82

I was hoping not to have to loop it. Just because it might slow down the process. I was hoping for a faster way. That was going to be my last resort. But... I'll see if i can get it working using the loops.

Share this post


Link to post
Share on other sites
FireFox

I was hoping not to have to loop it

What do you think the _ArraySearch function does?

 

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
blkshadow82

Fairly new to autoit so I haven't really looked into how everything works exactly. I know that functions like the arraybinarysearch said that it was faster. So I was hoping I could maybe figure out something using that or another method I haven't thought of.

Share this post


Link to post
Share on other sites
FireFox

I know that functions like the arraybinarysearch said that it was faster.

This algorithm works only on a sorted array.

Yours is sorted by date, but the first thing you're searching for is not sorted so you can't apply the algorithm on it.

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
blkshadow82

yea that's kind of what I thought. One more thing. I need my script to check if there are these values as well: "TRA-ADD" "PRT-DOD" "PRT-HCD" I tried adding them like this If $oEventgTable2[$r][1] <> "TOT-TRF" or "TRA-ADD" or "PRT-DOD" or "PRT-HCD" Then ContinueLoop

It didn't seem to work. It seemed to skip all of them. Is there a better way to do this then doing a loop for each individual value?

and thanks FireFox for all your help so far.

Share this post


Link to post
Share on other sites
FireFox

If $oEventgTable2[$r][1] <> "TOT-TRF" or "TRA-ADD" or "PRT-DOD" or "PRT-HCD" Then ContinueLoop
;is (because a string is 0 converted to expression)
If $oEventgTable2[$r][1] <> "TOT-TRF" or 0 or 0 or 0 Then ContinueLoop
;result can be (if $oEventgTable2[$r][1] = "TOT-TRF")
If 1 or 0 or 0 or 0 Then ContinueLoop ;True
;or (if $oEventgTable2[$r][1] <> "TOT-TRF")
If 0 or 0 or 0 or 0 Then ContinueLoop ;False

;should be
If $oEventgTable2[$r][1] <> "TOT-TRF" Or $oEventgTable2[$r][1] <> "TRA-ADD" Or $oEventgTable2[$r][1] <> "PRT-DOD" Or $oEventgTable2[$r][1] <> "PRT-HCD" Then ContinueLoop
All clear? :)

Br, FireFox.

Edited by 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
blkshadow82

oh yea forgot that minor detail.. But for some reason it is still skipping all of them.... It works fine when I only use one variable. I have a ton of if thens and loops so maybe I am doing something wrong somewhere else.. I'll try to figure it out. Thanks Firefox

Share this post


Link to post
Share on other sites
FireFox

oh yea forgot that minor detail..

Well, it's not :D

 

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
FireFox

Maybe you should use AND instead of OR ?


 

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
blkshadow82

you are my favorite person right now. Thanks got it working!

Share this post


Link to post
Share on other sites
FireFox

You're welcome sir ;)

Don't forget the helpfile, I advice the beta one as there are huge updates/fixes etc.


 

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  

×