syno Posted March 9, 2009 Share Posted March 9, 2009 Hi guys At the moment I am using StringInStr to find a particular string in a text file. However I need the search to return only the specific value. So for example if I am searching for the word 'findme' the search should only return true if 'findme' is found and return false if 'ufindme' is found Is this possible? I was thinking of using StringRegExp for this purpose but i am not sure.... Thanks Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 9, 2009 Share Posted March 9, 2009 Do you want the code to return true when "findme" is the only word in the text file, or the only word on a line? Please upload an example file if possible. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 9, 2009 Share Posted March 9, 2009 Hi guysAt the moment I am using StringInStr to find a particular string in a text file. However I need the search to return only the specific value. So for example if I am searching for the word 'findme' the search should only return true if 'findme' is found and return false if 'ufindme' is foundIs this possible? I was thinking of using StringRegExp for this purpose but i am not sure....ThanksYou haven't covered all the Boolean cases: What if neither is found... or both? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
syno Posted March 9, 2009 Author Share Posted March 9, 2009 Do you want the code to return true when "findme" is the only word in the text file, or the only word on a line? Please upload an example file if possible.At the moment my script says that a string is found if it finds 'findme' on a particular line. However I need my script to flag an error if it reads the following on line 2:line1line2findmeline2line2 Thanks Link to comment Share on other sites More sharing options...
florisch Posted March 9, 2009 Share Posted March 9, 2009 I do repeat the question: in what type of file do you try to find "findme"? Maybe just including spaces in the search string may do the trick ... " findme " Link to comment Share on other sites More sharing options...
syno Posted March 9, 2009 Author Share Posted March 9, 2009 You haven't covered all the Boolean cases: What if neither is found... or both? If neither is found my script will say that the file was not found, which is correct. Link to comment Share on other sites More sharing options...
syno Posted March 9, 2009 Author Share Posted March 9, 2009 I do repeat the question: in what type of file do you try to find "findme"?Maybe just including spaces in the search string may do the trick ..." findme "Nice try but this does not work as there are no spaces on the line which 'findme' excist's. The file I am searching is a .txt file opened in Notepad. Link to comment Share on other sites More sharing options...
Spiff59 Posted March 9, 2009 Share Posted March 9, 2009 I think you've now answered a couple of the questions in prior responses. Those regarding what specifically it is that you wish to do. To me, it's beginning to look like something as simple as: If FileReadLine($file) = "findme" Then ... is what you're after. Posting your code, or a portion of it, would likely clarify things for everyone here. Link to comment Share on other sites More sharing options...
SpookMeister Posted March 9, 2009 Share Posted March 9, 2009 Please give several more examples of desired and undesired parameters:For example, you want to successfully trigger off of "boo":The baby cried boo hoo hoo.I need to make a boolean expressionThe ghost shouted BOOBut you do not want:That subject is taboo.The engine got a sudden boost.12345boo890etc... We are trying to find a pattern and we are just guessing because you are not giving us enough to work with. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
syno Posted March 10, 2009 Author Share Posted March 10, 2009 Hi guys Thanks for everybodies suggestions. I think I have found a work around for this one. As it happens (by a supreme stroke of luck) each line of the text file I am reading has one space after it. Consequently when I assign the string to my variable I simply add the space, i.e $find='findme ' This then rules out me finding 'findme123' as opposed to just 'findme' when 'findme123' is in the text file... 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