icarrion Posted May 25, 2006 Share Posted May 25, 2006 I don't understand why $isActiveTable is returning a 1 meaning $tableArray is not an array when in fact it is. What's going on? Dim $tableArray[4] $var[1][0] = "my testing" _ArraySort( $tableArray) ; Lookup existing entry $isActiveTable = _ArrayBinarySearch ( $tableArray, $var[1][0] ) If Not @error Then Else EndIf Link to comment Share on other sites More sharing options...
Don N Posted May 25, 2006 Share Posted May 25, 2006 I think you getting this error because their is nothing in the $tableArray so it is generating an error because it is empty. I tried this and it worked... #include <Array.au3> Dim $tableArray[4] $tableArray[0] = "a" $tableArray[1] = "b" $tableArray[2] = "my testing" $tableArray[3] = "c" $var = "my testing" _ArraySort( $tableArray) ; Lookup existing entry $isActiveTable = _ArrayBinarySearch ( $tableArray, $var ) If Not @error Then MsgBox( 0, "", "Good" ) Else MsgBox( 0, "", "Bad" ) EndIf Hope this helps. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
icarrion Posted May 25, 2006 Author Share Posted May 25, 2006 I think you getting this error because their is nothing in the $tableArray so it is generating an error because it is empty. I tried this and it worked... #include <Array.au3> Dim $tableArray[4] $tableArray[0] = "a" $tableArray[1] = "b" $tableArray[2] = "my testing" $tableArray[3] = "c" $var = "my testing" _ArraySort( $tableArray) ; Lookup existing entry $isActiveTable = _ArrayBinarySearch ( $tableArray, $var ) If Not @error Then MsgBox( 0, "", "Good" ) Else MsgBox( 0, "", "Bad" ) EndIf Hope this helps. Thanks, but if I fill in the array with initial values then my return value for $isActiveTable is "" (empty)... which according to the docs say that the command failed. Is there a limit of chars that can go in an array? Also will chars like ' - ! screw it up? Thanks! Link to comment Share on other sites More sharing options...
Don N Posted May 25, 2006 Share Posted May 25, 2006 can you post the whole script here, it will be easier to find the problem that way. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
icarrion Posted May 25, 2006 Author Share Posted May 25, 2006 can you post the whole script here, it will be easier to find the problem that way. expandcollapse popup#include <GuiConstants.au3> #include <Array.au3> Opt("WinWaitDelay",100) Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced Dim $tableArray[4] $tableArray[0] = "empty" $tableArray[1] = "empty" $tableArray[2] = "empty" $tableArray[3] = "empty" While 1 $var = WinList("create") For $i = 1 to $var[0][0] ; sort the array to be able to do a binary search _ArraySort( $tableArray) ; Lookup existing entry $isActiveTable = _ArrayBinarySearch ( $tableArray, $var[$i][0] ) If Not @error Then ;do nothing Else Run("C:\Program Files\myapp\myapp.exe") _ArrayAdd( $tableArray, $var[$i][0]) WinWait("Insp","",3) WinActivate("Insp","") ControlClick("Insp", "", "Button5") WinWait ("Select Table","",3) WinActivate("Select Table","") $tableItem = ControlListView("Select Table", "", "SysListView321", "FindItem", StringLeft($var[$i][0],15), 1) ControlCommand ( "Select Table", "", "SysListView321", "SelectString", $var[$i][0] ) ControlClick("Select Table", "", "Button1") EndIf Next sleep(3000) Wend Link to comment Share on other sites More sharing options...
Don N Posted May 25, 2006 Share Posted May 25, 2006 Not entirely sure about this but when your code runs and you intiialize $tableArray to "empty" binary search is not going to ever find what your looking for and will return @error = 3 everytime and will always go into the if statememnt that does nothing. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
icarrion Posted May 25, 2006 Author Share Posted May 25, 2006 Not entirely sure about this but when your code runs and you intiialize $tableArray to "empty" binary search is not going to ever find what your looking for and will return @error = 3 everytime and will always go into the if statememnt that does nothing.Here is the goal I'm trying to accomplish.The program should reside in mem (ie While loop) and wait until a program is run (ie: Check active windows or $var = WinList("create")), after it finds the window that matches it will run another app separately lets call it the helper app. So for every main app that appears or opens it will need a helper app to acompany it. Seems easy enough, but the problem is that I can only open up 1 helper app per main app so that is why I'm having to search an array of already opened windows. So if the new window has not already been added then it should run the helper app and add it to the array of opened windows, but if it's already been added to the array then do nothing. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2006 Developers Share Posted May 25, 2006 How do you know that @error returns 1 ? Couldn't it be 3 ? (3 = If the item wasn't found in the array) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
icarrion Posted May 25, 2006 Author Share Posted May 25, 2006 How do you know that @error returns 1 ?Couldn't it be 3 ? (3 = If the item wasn't found in the array)Outputs a blank instead of a 0. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2006 Developers Share Posted May 25, 2006 Outputs a blank instead of a 0.No idea what you mean..... did you check the @error value ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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