Bea Posted April 22, 2018 Share Posted April 22, 2018 Hey i am trying to make a gui with a button formation button and than a msg box show if there were any errors and how often the script ist startet by reading a text file my problem is that i dont get it that the script scans for specific letters :S for example count only the "E" in the file the Goal is that the Script counts the "E" "B" and "S" in the text file but right now it only counts ever letter :S somone know how to fix it, pls help a girl $file = FileOpen("logs.txt", 0) $charcount = -1 ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Do $chars = FileRead($file, 1) $charcount += 1 Until @error = -1 MsgBox(4096, "Info", "Bilder geändert: "& $charcount _ & @CRLF & "Status geändert: " & $charcount _ & @CRLF & "FEHLER: " & $charcount ) FileClose($file) Exit Link to comment Share on other sites More sharing options...
kosamja Posted April 22, 2018 Share Posted April 22, 2018 $ReadFile = FileRead('logs.txt') StringReplace($ReadFile, 's', 's') $CountOfCharS = @extended Link to comment Share on other sites More sharing options...
Bea Posted April 22, 2018 Author Share Posted April 22, 2018 25 minutes ago, kosamja said: $ReadFile = FileRead('logs.txt') StringReplace($ReadFile, 's', 's') $CountOfCharS = @extended sry how i need to implant this dont know where to put it can u put it inside the cod <3 Link to comment Share on other sites More sharing options...
Subz Posted April 23, 2018 Share Posted April 23, 2018 Basically like this (untested). Local $iSCount, $iBCount, $iECount Local $sFileName = @ScriptDir & "\Logs.txt" If FileExists($sFileName) = 0 Then Exit MsgBox(4096, "Error", $sFileName & " could not be found.") Local $sFileText = FileRead('logs.txt') StringReplace($sFileText, 's', 's') $iSCount = @extended StringReplace($sFileText, 'b', 'b') $iBCount = @extended StringReplace($sFileText, 'e', 'e') $iECount = @extended MsgBox(4096, "Info", "Bilder geändert: "& $iBCount _ & @CRLF & "Status geändert: " & $iSCount _ & @CRLF & "FEHLER: " & $iECount) Link to comment Share on other sites More sharing options...
iamtheky Posted April 23, 2018 Share Posted April 23, 2018 do you need to count them all independently or just how many total? $str = "Test with 10 characters are either 'e' 's' or 'b'." msgbox(0, '' , ubound(StringRegExp($str , "e|s|b" , 3))) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Bea Posted April 23, 2018 Author Share Posted April 23, 2018 7 hours ago, iamtheky said: do you need to count them all independently or just how many total? $str = "Test with 10 characters are either 'e' 's' or 'b'." msgbox(0, '' , ubound(StringRegExp($str , "e|s|b" , 3))) I need them to count them all independet for example if in the text file there is written "bbsssfff" 2xb , 3xS, 3xF the rest works but by this purt i got stucked :S Link to comment Share on other sites More sharing options...
Nessie Posted April 23, 2018 Share Posted April 23, 2018 Try this: #include <MsgBoxConstants.au3> #include <FileConstants.au3> $sFilePath = @ScriptDir & "\log.txt" $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen = -1 Or Not FileExists($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Exit EndIf $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) StringReplace($sFileRead, "s", "s") $i_S_Count = @extended StringReplace($sFileRead, "b", "b") $i_B_Count = @extended StringReplace($sFileRead, "e", "e") $i_E_Count = @extended MsgBox($MB_ICONINFORMATION, "Info", "S occurrence: " & $i_S_Count & @CRLF & "B occurrence: " & $i_B_Count & @CRLF & "E occurrence: " & $i_E_Count) My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
Bea Posted April 23, 2018 Author Share Posted April 23, 2018 1 hour ago, Nessie said: Try this: #include <MsgBoxConstants.au3> #include <FileConstants.au3> $sFilePath = @ScriptDir & "\log.txt" $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen = -1 Or Not FileExists($sFilePath) Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Exit EndIf $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) StringReplace($sFileRead, "s", "s") $i_S_Count = @extended StringReplace($sFileRead, "b", "b") $i_B_Count = @extended StringReplace($sFileRead, "e", "e") $i_E_Count = @extended MsgBox($MB_ICONINFORMATION, "Info", "S occurrence: " & $i_S_Count & @CRLF & "B occurrence: " & $i_B_Count & @CRLF & "E occurrence: " & $i_E_Count) Man this worked Great, thank you so mouch i only have one question is it possible to color the numbers for example "E occurrence: 4" if that would be possible it would be great Link to comment Share on other sites More sharing options...
Nessie Posted April 23, 2018 Share Posted April 23, 2018 It is not possible with the standard MsgBox function. Also you can see that udf. Or just simply make a GUI My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
Subz Posted April 23, 2018 Share Posted April 23, 2018 Isn't that the same code I wrote? Link to comment Share on other sites More sharing options...
mikell Posted April 23, 2018 Share Posted April 23, 2018 6 hours ago, Subz said: Isn't that the same code I wrote? Seriously ? no. The icon in the MsgBox is not the same Subz and iamtheky 1 1 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