gcue Posted December 29, 2008 Share Posted December 29, 2008 hello, i have a variable ($s1Text) that equals this: " Cancel Searchresult No Documents Found " I'm not sure how to make this condition true: if $s1Text = "" then MsgBox(0, "Body Text", "true") EndIf i tried to count the number of line breaks and substituting them with & Chr(13) - but i couldnt get that to work... Link to comment Share on other sites More sharing options...
picaxe Posted December 29, 2008 Share Posted December 29, 2008 Maybe something like if StringRegExpReplace($s1Text, "\s", "") = "" then MsgBox(0, "Body Text", "true") EndIf Link to comment Share on other sites More sharing options...
gcue Posted December 29, 2008 Author Share Posted December 29, 2008 that didnt seem to work =/ any other ideas? Link to comment Share on other sites More sharing options...
Valuater Posted December 29, 2008 Share Posted December 29, 2008 *** TESTED OK *** $string = fileread("Tester.txt") $string = StringReplace($string, @CRLF, "") MsgBox(0x0, @extended, $string) 8) Link to comment Share on other sites More sharing options...
gcue Posted December 29, 2008 Author Share Posted December 29, 2008 brilliant! that works thanks bud Link to comment Share on other sites More sharing options...
GEOSoft Posted December 29, 2008 Share Posted December 29, 2008 Just a variation on Valuaters code that will only get the blank line count. $string = fileread("Tester.txt") StringRegExpReplace($string, "(?m:^)\v", "") MsgBox(4096, "Results", "There are " & @Extended & " empty lines") 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...
Valuater Posted December 29, 2008 Share Posted December 29, 2008 brilliant! that works thanks budWelcome@GEO ... 8) Link to comment Share on other sites More sharing options...
GEOSoft Posted December 29, 2008 Share Posted December 29, 2008 Welcome @GEO ... 8)Hope you realize that technically we are both incorrect. To get the count only the replace string should be the same as the search string. In your case $string = StringReplace($string, @CRLF, @CRLF) and in mine StringRegExpReplace($string, "(?m:^)(\v)", "$1") Also, using the regexp, it will get empty lines no matter what vertical character was used for the line terminator, char() 10 through 13 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...
PsaltyDS Posted December 29, 2008 Share Posted December 29, 2008 I think y'all been into the Egg Nogg and are over-thinking it a bit: If StringStripWS($s1Text, 8) = "" Then MsgBox(0, "Body Text", "true") EndIf 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...
GEOSoft Posted December 29, 2008 Share Posted December 29, 2008 (edited) I think y'all been into the Egg Nogg and are over-thinking it a bit: If StringStripWS($s1Text, 8) = "" Then MsgBox(0, "Body Text", "true") EndIf Everybody is missing the point that the OP asked for a COUNT of the blank lines. Edit: Actually I'm wrong In that. He just wants to replace all of the line breaks with Chr(13). Therefore my code should have been $string = fileread("Tester.txt") $string = StringRegExpReplace($string, "\r\n|\v", Chr(13)) That will replace any vertical WS character with Chr(13) and it wont matter if the line actually ended with @CRLF, @CR, @LF or a vertical tab or Form Feed Edited December 29, 2008 by GEOSoft 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...
PsaltyDS Posted December 29, 2008 Share Posted December 29, 2008 Everybody is missing the point that the OP asked for a COUNT of the blank lines. Edit: Actually I'm wrong In that. He just wants to replace all of the line breaks with Chr(13). Therefore my code should have been $string = fileread("Tester.txt") $string = StringRegExpReplace($string, "\r\n|\v", Chr(13)) That will replace any vertical WS character with Chr(13) and it wont matter if the line actually ended with @CRLF, @CR, @LF or a vertical tab or Form Feed Well, it would be best if gcue answered for himself, but the code he posted in post #1 was a test for a null string, that he seemed to want to be true even if there were multiple blank lines. The rest was about achieving that, which StringStripWS() does nicely. You've just been around Ron long enough that every problem looks like a RegExp! 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...
GEOSoft Posted December 29, 2008 Share Posted December 29, 2008 You've just been around Ron long enough that every problem looks like a RegExp! Are you syaing I've been brainwashed? Probably true. 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...
PsaltyDS Posted December 29, 2008 Share Posted December 29, 2008 (edited) Are you syaing I've been brainwashed? Probably true. Func _SmOke_N_Reeducation() $GEOSoft = StringRegExpReplace($GEOSoft, "[[:reality:]]", $NewSpeak) EndFunc Edited December 29, 2008 by PsaltyDS 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...
Moderators SmOke_N Posted December 29, 2008 Moderators Share Posted December 29, 2008 Func _SmOke_N_Reeducation() $GEOSoft = StringRegExpReplace($GEOSoft, "[[:reality:]]", $NewSpeak) EndFunc You've obviously not seen this rare occasion : http://www.autoitscript.com/forum/index.ph...st&p=622128 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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