deef99 Posted February 11, 2011 Share Posted February 11, 2011 I've read around the forum but haven't really found what I am looking for. I feel it's fairly simple, so maybe someone can assist me... I have a txt file that looks like this: 123456,800-232-2222,Project Blue 123423,800-232-2434,Red Clay .... about 200 lines. I need to do the following: 1. User enters the ID [which is the first 6 characters for EACH row. I believe I can do this with InputBox. 2. Now, search the text file for the ID. 3. Display the Information to the user as it appears in the file, no formatting required. I am stuck on #2....I think I can figure out how to display...if I can figure out how to get the line of data! Anyone got any code I can adjust that is similiar to this? Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
Djordhan Posted February 11, 2011 Share Posted February 11, 2011 That's pretty much it I think. Hope it helps! #include <File.au3> Global $sLookUpID = 000008 ;Replace with your input method Dim $aRecords If Not _FileReadToArray("C:\Temp.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If StringLeft($aRecords[$x], 6) = $sLookUpID Then Msgbox(0, "ID Found", $aRecords[$x]) Else ContinueLoop EndIf Next Link to comment Share on other sites More sharing options...
deef99 Posted February 11, 2011 Author Share Posted February 11, 2011 Ok...based on what you gave me, this is what I have so far. However, I need it to JUST DISPLAY the line for the ID that the user entered...not every line. Is there a way to do that? BTW...thank you very much for your fast and helpful response! #include "File.au3" #include "String.au3" #include <Array.au3> Opt("TrayMenuMode", 1) ;No icon in tray $file = "c:\avaya\logins.txt" Global $sLookUpID = InputBox("PHONE", "Enter Your Phone Extension:") Dim $aRecords If Not _FileReadToArray($file,$aRecords) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If StringLeft($aRecords[$x], 7) = $sLookUpID Then Msgbox(0, "ID Found", $aRecords[$x]) Else Msgbox(0, "NOT Found", $aRecords[$x]) ContinueLoop EndIf Next Link to comment Share on other sites More sharing options...
Djordhan Posted February 11, 2011 Share Posted February 11, 2011 The only thing that shows you every line here is your MsgBox in the else case in the For loop. If you remove that msgbox, only the one that fit the required id will show up. Link to comment Share on other sites More sharing options...
JoHanatCent Posted February 12, 2011 Share Posted February 12, 2011 Just need: #include "File.au3" #include "String.au3" #include <Array.au3> Opt("TrayMenuMode", 1) ;No icon in tray $file = "c:\avaya\logins.txt" Global $sLookUpID = InputBox("PHONE", "Enter Your Phone Extension:") Dim $aRecords If Not _FileReadToArray($file,$aRecords) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If StringLeft($aRecords[$x], 7) = $sLookUpID Then Msgbox(0, "ID Found", $aRecords[$x]) Next 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