Sign in to follow this  
Followers 0
Kogmedia

Help - Search Array - _ArraySearch

5 posts in this topic

#1 ·  Posted (edited)

Hello everyone,

I haven't been programing with autoit for very long. I have a problem and i can understand how I can work around it.

I want to search a txt file, and search for a specific word and return all the results but my problem keeps on giving me the first one it found?

Thanks,

Keith

Heres my code.

#Include<Array.au3>
#include <file.au3>
Dim $pricehistory,$found
$filename = "pricehistory.txt"
$apptile = "Search!"

$Input = InputBox("Price History Search", "Find?")
If @error Then Exit

If Not _FileReadToArray($filename,$pricehistory) Then
   MsgBox(4096,$apptitle, "Error reading watchlist:" & @error)
   Exit
EndIf
For $x = 1 to $pricehistory[0]
$found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True)
MsgBox(0,"Found",$found)
Next
Edited by Kogmedia

[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search

Share this post


Link to post
Share on other sites



ArraySearch() is not suitable for each line AFAIK as it will search the whole array at once. So use StringInStr().

For $x = 1 to $pricehistory[0]
    If StringInStr($pricehistory[$x], $Input) Then
        MsgBox(0,"Found", $Input)
    EndIf
Next

Share this post


Link to post
Share on other sites

#Include<Array.au3>
#include <file.au3>

Dim $pricehistory,$found
$filename = "pricehistory.txt"
$apptitle = "Search!"

$Input = InputBox("Price History Search", "Find?")
If @error Then Exit

If Not _FileReadToArray($filename,$pricehistory) Then
   MsgBox(4096,$apptitle, "Error reading watchlist:" & @error)
   Exit
EndIf

$found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True)
MsgBox(0,"Found",$found)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hello everyone,

I haven't been programing with autoit for very long. I have a problem and i can understand how I can work around it.

I want to search a txt file, and search for a specific word and return all the results but my problem keeps on giving me the first one it found?

Thanks,

Keith

Heres my code.

#Include<Array.au3>
#include <file.au3>
Dim $pricehistory,$found
$filename = "pricehistory.txt"
$apptile = "Search!"

$Input = InputBox("Price History Search", "Find?")
If @error Then Exit

If Not _FileReadToArray($filename,$pricehistory) Then
   MsgBox(4096,$apptitle, "Error reading watchlist:" & @error)
   Exit
EndIf
For $x = 1 to $pricehistory[0]
$found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True)
MsgBox(0,"Found",$found)
Next

Edit: changed For next to while wend

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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