yucatan Posted April 9, 2008 Share Posted April 9, 2008 hi i wanne make a script thats read a notepad document and if on the first rule is "" then ........ else ....... how do i need to make it i cant figure it out:S help me pleas Link to comment Share on other sites More sharing options...
YellowLab Posted April 9, 2008 Share Posted April 9, 2008 Dude, if you keep asking for people to write your scripts you won't learn. Read the help files, read the FAQs on this site and try a couple of things. This is like your third post asking for people to do your work for you. You can't see a rainbow without first experiencing the rain. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 9, 2008 Developers Share Posted April 9, 2008 (edited) hi i wanne make a script thats read a notepad document and if on the first rule is "" then ........ else .......how do i need to make it i cant figure it out:Shelp me pleaszucht, wat was er zo moeilijk aan mijn antwoord in een van je vele vorige vragen.Stop met het afvuren van nieuwe vragen totdat je ZELF eerst een poging doet om het ZELF te maken. Edited April 9, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
yucatan Posted April 9, 2008 Author Share Posted April 9, 2008 hi i'm trying to read a file and then compare it can somebody tell me what i'm doing wrong? $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $chars = FileRead($file, 1) If StringinStr($chars,"test") = 1 Then msgBox(4096, "ERREUR!", "er staat test") Else msgBox(4096, "ERREUR!", "anders") EndIf Link to comment Share on other sites More sharing options...
James Posted April 9, 2008 Share Posted April 9, 2008 (edited) Please use [ code ] [ / code] tags (without spaces) please Take a look at StringCompare() Edited April 9, 2008 by JamesB Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
yucatan Posted April 9, 2008 Author Share Posted April 9, 2008 hmm i dont know why jos is whining again but i did try it and i did searched but i realy cant find it i thout that a forum is for when you haveing problems with things.... Link to comment Share on other sites More sharing options...
yucatan Posted April 10, 2008 Author Share Posted April 10, 2008 hi can somebody tell me why i get error's what i'm doing wrong in string compare? $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $chars = FileRead($file, 1) if StringCompare ("$chars", "test" [, 0]) = 0 Then MsgBox(0, "er staat test") Else MsgBox(0, "anders") EndIf Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 10, 2008 Share Posted April 10, 2008 (edited) "test" [, 0] What is that supposed to be? That's not valid syntax. Oh, and you don't access variables by using the name in strings. You would read the value of $chars by just using $chars, not "$chars". Edited April 10, 2008 by Richard Robertson Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2008 Developers Share Posted April 10, 2008 hmm i dont know why jos is whining again but i did try it and i did searched but i realy cant find it i thout that a forum is for when you haveing problems with things....I am not and if you would have bothered to look at the details you could have concluded that I merged the 2 Threads. So next time think before making stupid smart remarks. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2008 Developers Share Posted April 10, 2008 (edited) OK, now I am going to do a bit more whining: Stop creating new topic about the same issue! Next time they will be simply locked. I have merged them again. Edited April 10, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 10, 2008 Share Posted April 10, 2008 When you see the square bracket used in the help file it indicates an option. They should not be included in the line. if StringCompare ($chars, "test" , 0) = 0 In the case of StringCompare, 0 is the default so it's not required at all. The line above is the same as if StringCompare ($chars, "test") = 0 On top of all that I have a hunch that what you are looking for is more along the lines of StringInStr() If StringInStr($chars, "test") Then 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...
yucatan Posted April 10, 2008 Author Share Posted April 10, 2008 (edited) hi i have tryid it with If StringInStr($chars, "test") Then but when i use Else then i get syntax error's why is that and he always say there is not standing test but i'm sure that in that document is writen test.... how is this possebel ? FileChangeDir (@DesktopDir) $file = FileOpen("test.bat", 0) $chars = FileRead($file, 1) if StringCompare ($chars, "test") = 0 Then MsgBox(0, "Error", "er staat test") this is the code now i'm sure that in test.bat is standing test but it dont say er staat test why it dont work i just am searching and searching i cant find it:( Edited April 10, 2008 by yucatan Link to comment Share on other sites More sharing options...
MHz Posted April 11, 2008 Share Posted April 11, 2008 You cannot put statements on the same line as "Else" as to why you are getting a syntax error. This example may help you to understand. ; Check that working directory changes to @DesktopDir If FileChangeDir(@DesktopDir) Then ; Open a file handle for read $handle = FileOpen('test.bat', 0) ; Check if the handle is valid If $handle <> -1 Then ; Read the complete file $text = FileRead($handle) ; Find "test" with $text if StringInStr($text, "test") Then ; Show Msgbox if StringInStr returns not 0 MsgBox(0, '', '"test" found') Else ; Show Msgbox if StringInStr returns 0 MsgBox(0, '', '"test" not found') EndIf ; Close the file handle FileClose($handle) EndIf EndIf Have a look in the help file contents for "If...ElseIf...Else...EndIf" for syntax that is valid. Link to comment Share on other sites More sharing options...
Swift Posted April 11, 2008 Share Posted April 11, 2008 And like he said. Use ortags please. Example: Using code: [Code] Now watch: Hey... And AutoIt: [AutoIt]Hey! Link to comment Share on other sites More sharing options...
therks Posted April 11, 2008 Share Posted April 11, 2008 Swift, I have a feeling your post didn't come out quite like you intended it to. For anyone, if you ever want to show someone how to use the [code] or [autoit] tags, just put an empty bold (or strike, italics, etc) tag inside the tag, like this: [[b][/b]code]. This will print: [code]. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Brenda1 Posted April 11, 2008 Share Posted April 11, 2008 yoo have to do a loop, for read all the document, it can be like this: While 1 $LineRead = FileReadLine($file) If @error = -1 Then ExitLoop $array = StringSplit($LineRead, ";") If $Variable = $array[1] then; put the position you want to compare [conditions] endif Wend don't forget to open the file first, in a read mode. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 11, 2008 Share Posted April 11, 2008 You are aware that FileReadLine() is the slowest possible method of reading a file, are you not? Better to read the file to an array than to do that. 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...
Brenda1 Posted April 11, 2008 Share Posted April 11, 2008 You are aware that FileReadLine() is the slowest possible method of reading a file, are you not? Better to read the file to an array than to do that.it is up to the file you want to read... 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