BrokenDynasty Posted June 29, 2004 Share Posted June 29, 2004 How would one search a .txt file (existing) for either a defined variable or a certain string? I figured out how to create a .txt file, and how to input data into it (from a variable), but I would like to know how to then search the text file to see if it contains a given string or variable. Link to comment Share on other sites More sharing options...
pekster Posted June 29, 2004 Share Posted June 29, 2004 It sounds like you already have all the tools you need. Open the file for reading, and read in a line at a time. Test the line to see if it contains the string you're searching for and if so do something about it. If you don't find it in all the lines, then do something else about it. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
BrokenDynasty Posted June 29, 2004 Author Share Posted June 29, 2004 Yeah I figured it out before I had the chance to delete my post. Another question for you. Is there a way to edit the attributes of a text file my program creates? Right now it creates sample.txt and writes in data taken from an input box, then next time the program is run it calls up the info from the text file. How can I make the text file hidden? Link to comment Share on other sites More sharing options...
pekster Posted June 29, 2004 Share Posted June 29, 2004 (edited) FileSetAttrib -------------------------------------------------------------------------------- Sets the attributes of one or more files. FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse] ) Edited June 29, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
BrokenDynasty Posted June 29, 2004 Author Share Posted June 29, 2004 I'm sorry my questions are all answerable using the help files. I am not entirely familiar with the program, but you all are helping me learn it much quicker then on my own. I appreciate the time it takes you to quote the help file to point me in the right direction. Link to comment Share on other sites More sharing options...
Arctor Posted June 29, 2004 Share Posted June 29, 2004 One small note: The helpfile has a search function. For example if you put in "attrib" it leads you in the right direction. If the hit is not perfect there are related links. This helpfile is great, has examples and can help a lot. arctor Link to comment Share on other sites More sharing options...
pekster Posted June 29, 2004 Share Posted June 29, 2004 It takes a bit of time to get used to using the helpfile. You might even want to briefly skim the various functions. That way, you may not know the exact function you want, but you'll at least have read about the section it comes from. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Arctor Posted June 30, 2004 Share Posted June 30, 2004 Hi Pekster I do not hope you missunderstand me. My note was not a flame to BrokenDynasty. It was just a hint that working with this helpfile is really great. I remember my first 6 hours with au3 GUI. Not a month ago. I did'nt know anything about autoit and GUI programming. I just have a bit experience with batch scripting and php. The first 2 hours I studied the helpfile and did simple things with the help of the examples and had a look at syntax and stuff. After that I made a script which takes my input, pass it to a CLI prog asking a mysql database and get the result back into a textfile and from there to a listbox. In this 6 hours I didn't even visit google. I just worked with the helpfile. I dont't say this because I am a big programmer. Really I am not! I say this because this is a cool understandable powerful language. And a really great helpfile. It's well structured has related links and for me the most important: It has examples. And the best of all: AutoIt has a good forum with nice and patient (the fishing topic) people. arctor Link to comment Share on other sites More sharing options...
pekster Posted June 30, 2004 Share Posted June 30, 2004 Hi Pekster...Actually, I started my responce before I saw yours, so I wasn't trying to add something you forgot. I posted, and yours was there before mine. No misinterpretation can occur if I didn't first interpret it go begin with [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
BrokenDynasty Posted June 30, 2004 Author Share Posted June 30, 2004 Thanks for your help guys/girls...my program is coming along, I will be sure to check the helpfile more thoroughly before I post any more questions. Link to comment Share on other sites More sharing options...
Doxie Posted June 30, 2004 Share Posted June 30, 2004 I just woke up and are still "sleeping" ?! But, if you use AutoIt to create the file, you can use IniWrite, and write into sections, wich will make it easier for you to find the info you are looking for. A short example: IniWrite($SD & "info.ini", "Info", "Local IP", @IPAddress1) $IP = IniRead($SD & "info.ini", "InfoL", "Local IP", "") MsgBox(4096,"IP","My IP is: " & $IP) That´s not really a good example, since you could do that with one line, but you get the idea One Line: MsgBox(4096,"IP","My IP is: " & @IPAddress1) Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
tutor2000 Posted July 1, 2004 Share Posted July 1, 2004 It sounds like you already have all the tools you need. Open the file for reading, and read in a line at a time. Test the line to see if it contains the string you're searching for and if so do something about it. If you don't find it in all the lines, then do something else about it.How about$var = FileRead ("mypath\my.txtr", FileGetSize ("mypath\my.txt ))if stringinstr ($var,"mystring") thenmsgbox(4096,"Hurray","Only one line of code and I don't have to read line by line")endifJust kidding around but I use that a lot. Got it from GeneRick Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm 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