Syed23 Posted November 23, 2010 Share Posted November 23, 2010 Hi Friends, I need your help to find solution. I have a string in my text file like this "Name=Syed,Age=23,Sex=Male,Interest=Tool creation". so all i wanted is that i should check whether the line have the "string - male" on it. Can some one help me on this? Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
water Posted November 23, 2010 Share Posted November 23, 2010 Hi Friends, I need your help to find solution. I have a string in my text file like this "Name=Syed,Age=23,Sex=Male,Interest=Tool creation". so all i wanted is that i should check whether the line have the "string - male" on it. Can some one help me on this? If you have more than one line in your text file I would do something like: #include <file.au3> _FileReadToArray("C:\temp\test.txt", $aResult) For $iIndex = 1 To $aResult[0] If StringInStr($aResult[$iIndex], "Sex=Male") Then ; Do whatever you want for every male in your file EndIf Next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GEOSoft Posted November 23, 2010 Share Posted November 23, 2010 Easier yet, avoid the array $sStr = FileRead("C:\temp\test.txt") If StringInStr($sStr, "Sex=Male") Then ; Do whatever you want for every male in your file EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Syed23 Posted November 23, 2010 Author Share Posted November 23, 2010 If you have more than one line in your text file I would do something like: #include <file.au3> _FileReadToArray("C:\temp\test.txt", $aResult) For $iIndex = 1 To $aResult[0] If StringInStr($aResult[$iIndex], "Sex=Male") Then ; Do whatever you want for every male in your file EndIf Next Thanks a lot!! This is what i wanted exactly... you are amazing. MAy i know your name? I am Syed. Could you please explain me how it works.. because i wanted to do if some thing needed to work with string in futurer. Will you please?? Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
SadBunny Posted November 23, 2010 Share Posted November 23, 2010 Thanks a lot!! This is what i wanted exactly... you are amazing. MAy i know your name? I am Syed. Could you please explain me how it works.. because i wanted to do if some thing needed to work with string in futurer. Will you please??It reads the file into an array, every line goes into one array element. Then it works through the array and for every line it encounters, it checks whether the line contains "Sex=Male". If the line contains that string, it does the "whatever you want" line.About your question "because i wanted to do if some thing needed to work with string in futurer."... I'm not sure how to answer that... Btw, I'm SadBunny... Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Syed23 Posted November 23, 2010 Author Share Posted November 23, 2010 It reads the file into an array, every line goes into one array element. Then it works through the array and for every line it encounters, it checks whether the line contains "Sex=Male". If the line contains that string, it does the "whatever you want" line.About your question "because i wanted to do if some thing needed to work with string in futurer."... I'm not sure how to answer that... Btw, I'm SadBunny... Thanks a lot Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] 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