hogfan Posted November 18, 2022 Posted November 18, 2022 Hello, I'm having an issue with incorrect/unexpected results returning from the second of two _ArraySearch functions I'm executing in my function below. Both arrays are declared globally. The _ArraySearch called in the first For/Next loop is behaving as expected. However, the _ArraySearch called in the second For/Next loop is not returning the expected results. I've attached my sample project and some sample/dummy files for testing/recreating the issue. Any assistance is appreciated. I'm sure I'm missing something simple but can't seem to find it in my code. Here's the problematic function as well as a screenshot illustrating my problem with the second _ArraySearch in my function. expandcollapse popup;################################################################################################################################# ;Load Local Libary button click ;Import remote movie library from a txt/mlf file and compare it against the local libary to identify missing movies in each libary ;################################################################################################################################# Func _ImportAndCompare () ;Present a fileopen dialog box for the user to select a movie library file to import Local $sFileOpenDialog = FileOpenDialog("Import Libary File to Compare...","", "Movie Libary File (*.mlf)", $FD_FILEMUSTEXIST) ;read the selected movie list file (.mlf) into a 1D array _FileReadToArray($sFileOpenDialog, $arrImportCompare) ;ensure the Remote Movie Library Listbox & Local and Remote Missing listboxes are empty GUICtrlSetData($lstRemoteLib, "") GUICtrlSetData($lstLocalMissing, "") GUICtrlSetData($lstRemoteMissing, "") ;loop through the array, adding each movie to the Remote Movie Library listbox For $i= 1 to UBound($arrImportCompare,1) -1 $strMovieTitle = $arrImportCompare [$i] GUICtrlSetData($lstRemoteLib, $strMovieTitle) ;for each movie in the $arrImportCompare array, search for it in the $arrLocalLib array. if not add them to Local Missing Listbox _ArraySearch($arrLocalLib,$strMovieTitle, 0, 0, 0, 3) If @error Then ;searched movie not found in $arrLocalLib, add it to the Local Library is Missing listbox ($lstLocalMissing) GUICtrlSetData($lstLocalMissing, $strMovieTitle) Else ;Do Nothing EndIf Next ;After the imported movie list has been loaded into the Remote Movie Library Listbox, and movies in the remote libary have been identified and added _ ;to the Local Library is Missing listbox, loop through the $arrLocalLib and search for movies missing in the remote movie libary ;Loop through the $arrLocalLib array and search to see if each movie exists in the remote library ($arrImportCompare), if not add it to the Remote Missing Listbox ($lstRemoteMissing) For $i= 1 to UBound($arrLocalLib,1) -1 $strMovieTitle = $arrLocalLib [$i] ;check if the movie exists in the remote Library _ArraySearch($arrImportCompare,$strMovieTitle) If @error Then ;searched movie not found in $arrImportCompare, add it to the Remote Library is Missing listbox ($lstRemoteMissing) GUICtrlSetData($lstRemoteMissing, $strMovieTitle) Else ;Do Nothing EndIf Next EndFunc Movie Libary Comparison Tool.zip
AndyG Posted November 18, 2022 Posted November 18, 2022 (edited) Hi! As always in this cases (I know what I am talking about 🐵 , sometimes I "don´t see the wood for the trees" also) ...look at what you are posting in the picture....you compare "Elvis" with "Elvis.mkv"...that doesn´t work 😃 You have to trim the extension ".mkv" from the title, thats all! In Line 190 $strMovieTitle = StringTrimRight($arrLocalLib [$i],4) ;trims the extension from filename Edited November 18, 2022 by AndyG
hogfan Posted November 18, 2022 Author Posted November 18, 2022 15 hours ago, AndyG said: Hi! As always in this cases (I know what I am talking about 🐵 , sometimes I "don´t see the wood for the trees" also) ...look at what you are posting in the picture....you compare "Elvis" with "Elvis.mkv"...that doesn´t work 😃 You have to trim the extension ".mkv" from the title, thats all! In Line 190 $strMovieTitle = StringTrimRight($arrLocalLib [$i],4) ;trims the extension from filename Thank you! lol I figured it was something simple! I see the issue now in the code! In my _LoadLocalLibrary function I'm using the following line to remove the file extension before adding the movie to the Local Library listbox........but when I loop through the $arrLocalLib again down in my _ImportAndCompare function, I wasn't removing the file extension as you pointed out. Thanks again! ;Loop through each item/movie title in the array, remove the file .file extension, and add it to the Local Movie Libary listbox For $i= 1 to UBound($arrLocalLib,1) -1 $strMovieTitle = $arrLocalLib [$i] $strMovieTitle = StringLeft($strMovieTitle,StringInStr($strMovieTitle,".",Default,-1)-1) GUICtrlSetData($lstLocalLib, $strMovieTitle) Next[/Code]
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