Rammanan Posted April 9, 2019 Share Posted April 9, 2019 Hi all, I'm really stuck on array search. Please refer the attach for array display. It select LSD_6_INCH_ENG but correct string is LSD_6_INCH. Please advise to solve this issues. $Search = _ArraySearch($aRecords, $Recipe,0,$count,0,1,3,0) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 9, 2019 Share Posted April 9, 2019 @Rammanan It's difficult to say without seeing the content of $Recipe variable Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 @FrancescoDiMuro $Recipe = LSD_6_INCH Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 9, 2019 Share Posted April 9, 2019 @Rammanan Global $arrArray[12] = [12, _ "ENGINEERING_REWORK_FBAR", _ "LSD_6_INCH_ENG", _ "LSD_8_INCH_ENG", _ "CHOOI-Humming", _ "ENGINEERING_BUYOFF_6_INCH", _ "1213", _ "MOLOKAI_LSD_13_MIL", _ "LSD_6_INCH", _ "FBAR_6_INCH", _ "LSD_IDT_10MIL", _ "LSD_8_INCH"], _ $strSearch = "LSD_6_INCH", _ $intIndex = -1 $intIndex = _ArraySearch($arrArray, $strSearch) If @error Then ConsoleWrite("_ArraySearch() ERR: " & @error & @CRLF) Else ConsoleWrite("Index: " & $intIndex & @CRLF) EndIf Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 @FrancescoDiMuro Need hard code the string to search. Problem is array display not same to all machine. Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2019 Share Posted April 9, 2019 2 hours ago, Rammanan said: @FrancescoDiMuro Need hard code the string to search. Problem is array display not same to all machine. No, Francesco was giving you an example. The problem is that YOUR _ArraySearch is badly formatted. Please refer to Help File, to understand each parameter. Look especially at the sixth parameter... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 @Nine I really not understand to work on array search. 😞 Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2019 Share Posted April 9, 2019 Try using : $Search = _ArraySearch($aRecords, $Recipe,0,0,0,2) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 Local $Recipe = "LSD_6_INCH" Dim $aRecords If Not _FileReadToArray("C:\temp\recipe.txt",$aRecords) Then ;(Read txt file at local c) ;MsgBox(4096,"Error", " Error reading log to Array error:" & @error) ConsoleWrite("Error: Script cannot find C:\temp\recipe.txt file") Local $1open = FileOpen("C:\Temp\error.txt",1) Local $write = FileWrite($1open,"Error: Script cannot find C:\temp\recipe.txt file to read recipe") FileClose($1open) FileDelete("C:\Temp\recipe.txt") Exit EndIf _ArrayDisplay($aRecords, "Entries left in the array") _ArrayPop($aRecords) ;(Delete last entry at array) $aArray = _ArrayDisplay($aRecords, "Entries left in the array") $Search = _ArraySearch($aRecords, $Recipe,0,0,0,2) MsgBox(32,'',$Search) Return get -1 Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2019 Share Posted April 9, 2019 I thought it was a 1d array, if not try $Search = _ArraySearch($aRecords, $Recipe,0,0,0,2,1,0) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 1d array right? But still get -1 Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2019 Share Posted April 9, 2019 Maybe some hidden characters (space at the end for example)...Check for that in your recipe.txt file. FrancescoDiMuro 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 recipe.txt file look like this. No space Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2019 Share Posted April 9, 2019 upload the file, i'll look at it... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Subz Posted April 9, 2019 Share Posted April 9, 2019 Try a partial search, if this returns the correct index item, then as Nine mentioned there is probably a hidden character. $Search = _ArraySearch($aRecords, $Recipe,0,0,0,1) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 9, 2019 Share Posted April 9, 2019 1 hour ago, Rammanan said: recipe.txt file look like this. No space You should take a look with Notepad++, or any other text editor which let you see special characters like spaces, new line, and so on Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
iamtheky Posted April 9, 2019 Share Posted April 9, 2019 (edited) Is it the same behavior on the LSD_8_INCH lines? Or is this behvaior unique to the 6 inchers? Those are just some of the myriad questions that abound until the source file is produced. ***to end speculation you could just run a stringstripws for leading and trailing (and maybe just trailing..) as we would see all others in the notepad screenshot. Unless yall know cool ways to hide shit in the middle of a string in notepad, which you need to show me. Edited April 9, 2019 by iamtheky FrancescoDiMuro 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 9, 2019 Share Posted April 9, 2019 1 minute ago, iamtheky said: Unless yall know cool ways to hide shit in the middle of a string in notepad, which you need to show me. Sick Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Rammanan Posted April 9, 2019 Author Share Posted April 9, 2019 @Nine i have attach the file. I check using notepad++ but no space show recipe.txt Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 9, 2019 Share Posted April 9, 2019 (edited) @Rammanan 9 minutes ago, Rammanan said: I check using notepad++ but no space show Each line in the file contains spaces, so, you should do something like this: #include <Array.au3> #include <StringConstants.au3> Global $arrArray, _ $strSearch = "LSD_6_INCH", _ $intIndex = -1 _FileReadToArray(@ScriptDir & "\recipe.txt", $arrArray) If @error Then Exit ConsoleWrite("_FileReadToArray() ERR: " & @error & @CRLF) $arrArray = StringRegExp(StringStripWS(_ArrayToString($arrArray), $STR_STRIPALL), '([^|]+)', $STR_REGEXPARRAYGLOBALMATCH) $intIndex = _ArraySearch($arrArray, $strSearch) If @error Then ConsoleWrite("_ArraySearch() ERR: " & @error & @CRLF) Else ConsoleWrite("Index: " & $intIndex & @CRLF) EndIf Edited April 9, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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