madasraka Posted February 26, 2011 Share Posted February 26, 2011 Im doing basic filesearch, but with the returned result in the loop instead of showind it up in guyctrlcreateedit i want it to create new variable for each found file. There can be 100's of files found and displaying them in the edit box is good idea to see them, but to read individual file name from editbox is complicated. IS there a way to make my script to "once found file matchinc the pattern" create new variable and assign filename to that variable ? This way i dont have to create 1000000 variables in my script in case if there are 1000000 files found $SearchHandle = FileFindFirstFile ($Address & "\" & $Pattern) ;pattern *.* While 1 $Search = FileFindNextFile ($SearchHandle) If $Search > "" Then Assign ("created variable ?",$Search,2) ;2 to create global ? GUICtrlSetData ($List,$Search & @CRLF,"Edit") ; put found name into editbox Else ExitLoop EndIf WEnd At the "Assign ("created variable ?",$Search,2)" its not creating anything as i would expect it too. Is there something wrong or i dont understand how this works ? Please help, this bugges me for a very long time and puts my work to limits allot. Link to comment Share on other sites More sharing options...
SKhan Posted February 26, 2011 Share Posted February 26, 2011 (edited) #include <GUIConstants.au3> #include<Array.au3> $n=0 Local $nFiles[2] $nFiles[0] = "" $FileHandle = FileFindFirstFile("C:\Users\Khan\Documents\*.*") If Not @error Then While 1 $n=$n+1 ;Count ReDim $nFiles[$n+1] ;Changes the array size to add one more "Found" file $nFiles[$n] = FileFindNextFile($FileHandle) If @error Then ExitLoop ;When it finds no more files with the pattern, it will stop adding file paths to the array. WEnd EndIf ReDim $nFiles[$n-1] ;Removes the last blank line $nFiles[0] = $n-2 ; sets $nFiles[0] to state the number of files found $GUI = GUICreate("List", 500, 300) $List = GUICtrlCreateList("", 10, 10, 480, 280) For $i=1 To $nFiles[0] GUICtrlSetData($List, $nFiles[$i] & "|") Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd $nFiles[0] returns the number of files it found was this helpful? Edited February 27, 2011 by SNawazK786 Link to comment Share on other sites More sharing options...
madasraka Posted February 27, 2011 Author Share Posted February 27, 2011 LOL ofcourse i need help One thing i see here is _ArrayDisplay I dont need it to be displayed as poped out of nowhere. It must be shown as part of GUI instead of editbox. But thanks i will look into this harder this time. Link to comment Share on other sites More sharing options...
Yashied Posted February 27, 2011 Share Posted February 27, 2011 Using ReDim is not a good idea because it reduces the enumerating speed. #Include<Array.au3> $List = '' $hSearch = FileFindFirstFile(@SystemDir & '\*') If $hSearch <> -1 Then While 1 $File = FileFindNextFile($hSearch) If @error Then ExitLoop If Not @extended Then $List &= $File & ';' WEnd EndIf $List = StringSplit(StringTrimRight($List, 1), ';', 2) _ArrayDisplay($List) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
madasraka Posted February 27, 2011 Author Share Posted February 27, 2011 (edited) Ok this is interesting:: My script 1st searches and outputs found files into editbox (not into array) Then with a press of another button i want to move found files. Problem is that i cant move those files without stringing whole editbox (somehow) to read individual filenames to move one at the time. So i thought if once files found and displayed, each found file would also have its own $n bumber to which i can refference in filemove command. for example: Picture shows that there are multiple file names reflected in editbox How do i read those filenames off that editbox in loop function and move those files (rename in this case)? I could do the search and move again using your examples, but then it wont be "Move listed" since user might remove some files from the list. Edited February 28, 2011 by madasraka Link to comment Share on other sites More sharing options...
madasraka Posted February 28, 2011 Author Share Posted February 28, 2011 (edited) bump How do i read those filenames off that editbox in loop function and move those files (rename in this case)? I could do the search and move again using your examples, but then it wont be "Move listed" since user might remove some files from the list. If possible then maybe create a new variable for every single found file, so then i can use those variables, but then i dont know how to get this done. Edited February 28, 2011 by madasraka Link to comment Share on other sites More sharing options...
kylomas Posted February 28, 2011 Share Posted February 28, 2011 madasraka, Don't know if it is possible...do NOT think that it is advisable! Why not use Yashied's example and process the files out of an array..it is plenty quick kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted February 28, 2011 Share Posted February 28, 2011 (edited) madasraka, ALso: you are referencing an "edit box" but the code provided uses a list control. Guictrlread handles both, but differently. kylomas addendum: I wrote a possible solution to this post but did not provide for dynamic renaming..was working on that but is now on the back burner. Am interested in whatever solution you come up with. Edited February 28, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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