gamepin126 Posted June 8, 2006 Posted June 8, 2006 Is there any way to get the total count of characters in a txt file, or maybe make a GUI that will count every character typed (or pasted) into it? I post a lot of tutorials and links into websites and this would be really useful for me. I just need ideas on how to go about it, I could probably write it myself.
BigDod Posted June 8, 2006 Posted June 8, 2006 Probably a silly idea but here goes. Read file Strip carraige returns use StringSplit with space as the delimiter then Array[0] should contain amount of words. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
Xenobiologist Posted June 8, 2006 Posted June 8, 2006 HI, may be a beginning. expandcollapse popup$var = FileOpenDialog("TextFile", "C:\", "Txt-files (*.txt)", 1 );+ 4 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) MsgBox(4096,"","You chose " & $var) EndIf $count = 0 For $i = Asc('a') To Asc('z') $CharCount = _CountChars($var, Chr($i), 1) If $CharCount Then $count = $count + 1 ConsoleWrite($count & '.' & @TAB & '[' & Chr($i) & '] ' & $CharCount & @LF) EndIf Next For $x = Asc('A') To Asc('Z') $CharCount = _CountChars($var, Chr($x), 1) If $CharCount Then $count = $count + 1 ConsoleWrite($count & '.' & @TAB & '[' & Chr($x) & '] ' & $CharCount & @LF) EndIf Next For $x = Asc('0') To Asc('9') $CharCount = _CountChars($var, Chr($x), 1) If $CharCount Then $count = $count + 1 ConsoleWrite($count & '.' & @TAB & '[' & Chr($x) & '] ' & $CharCount & @LF) EndIf Next Func _CountChars($h_File, $v_Char, $i_CaseSensitive = 0); 1 = Case Sensitive If Not FileExists($h_File) Then SetError(1) Return 0 EndIf If $i_CaseSensitive = 0 Then $a_Split = StringSplit(StringLower(FileRead($h_File, FileGetSize($h_File))), $v_Char) ElseIf $i_CaseSensitive = 1 Then $a_Split = StringSplit(FileRead($h_File, FileGetSize($h_File)), $v_Char) Else SetError(2) Return 0 EndIf Return UBound($a_Split) - 2 EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
marfdaman Posted June 8, 2006 Posted June 8, 2006 (edited) $file = FileOpen(@DesktopDir & "\Muzen.txt", 0) $string = FileRead($file) MsgBox(0, $string, $string) $num = 0 For $i = 32 To 255 StringReplace($string, Chr($i), "") $num = $num + @extended Next MsgBox(0, $num, $num) Edit: lol could be so simple... Edited June 8, 2006 by marfdaman Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Busti Posted June 8, 2006 Posted June 8, 2006 filegetsize( "bla.txt" ) My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
seandisanti Posted June 8, 2006 Posted June 8, 2006 filegetsize( "bla.txt" )that's the way i always do it... like to read in an entire text file you do: $contents = FileRead("C:\blah.txt",FileGetSize("C:\blah.txt"))
Moderators SmOke_N Posted June 8, 2006 Moderators Posted June 8, 2006 filegetsize( "bla.txt" )Ding Ding Ding!! lol... $StringLen = StringLen(FileRead('results.txt')) $FileSize = FileGetSize('results.txt') MsgBox(64, 'info', $StringLen & @CR & $FileSize) 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.
gamepin126 Posted June 8, 2006 Author Posted June 8, 2006 $file = FileOpen(@DesktopDir & "\Muzen.txt", 0) $string = FileRead($file) MsgBox(0, $string, $string) $num = 0 For $i = 32 To 255 StringReplace($string, Chr($i), "") $num = $num + @extended Next MsgBox(0, $num, $num)oÝ÷ ØGb¶Z%r¥u·¬¢È¦¦Wþ«¨µå¨ÂØZKz··öËaz¢"fy«¢+Ø¥¹±Õ±ÐíÕ¥ ½¹ÍѹÑ̹ÔÌÐì()Õ¥ ÉÑ ÅÕ½Ðí ¡É ½Õ¹ÐÅÕ½Ðì°ÌÀÀ°ÈÀÀ°´Ä°´Ä° ¥Ñ=H ÀÌØí]M}=YI1AA]%9=°ÀÌØí]M} 1%AM% 1%9L¤¤((ÀÌØí¥Ñ|ÄôÕ¥ Ñɱ ÉѥРÅÕ½Ðí%¹ÁÕÐQáÐ!ɸÅÕ½Ðì°À°ÈÀ°ÌÀÀ°ÄàÀ¤(ÀÌØí1±|ÈôÕ¥ Ñɱ ÉÑ1° ÅÕ½ÐíQ½Ñ° ¡ÉÌèÅÕ½Ðì°À°À°ØÀ°ÈÀ¤(ÀÌØí1±|ÌôÕ¥ Ñɱ ÉÑ1° ÅÕ½Ðí¹ÕµÈÅÕ½Ðì°ÜÀ°À°ÄÈÀ°ÈÀ¤(ÀÌØí ÕÑѽ¹|ÐôÕ¥ Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½ÐíMÕµ¥ÐÅÕ½Ðì°ÈÀÀ°À°ÄÀÀ°ÈÀ¤)Õ¥MÑMÑÑ ¤)]¡¥±Ä($ÀÌØíµÍôÕ¥Ñ5Í ¤(%M±Ð($% ÍÀÌØíµÍôÀÌØí ÕÑѽ¹|Ð($$$íøÀÌØí¥±ô¥±=Á¸¡ÍѽÁ¥ÈµÀìÅÕ½ÐìÀäÈí5Õ鸹ÑáÐÅÕ½Ðì°À¤($$$ÀÌØíÍÑÉ¥¹ôÕ¥ ÑɱI ÀÌØí¥Ñ|Ĥ($$$íø5Í ½à À°ÀÌØíÍÑÉ¥¹°ÀÌØíÍÑÉ¥¹¤($$$ÀÌØí¹Õ´ôÀ($$%½ÈÀÌØí¤ôÌÈQ¼ÈÔÔ($$%MÑÉ¥¹IÁ± ÀÌØíÍÑÉ¥¹° ¡È ÀÌØí¤¤°ÅÕ½ÐìÅÕ½Ðì¤($$$ÀÌØí¹Õ´ôÀÌØí¹Õ´¬áѹ($$%9áÐ($$%Õ¥ ÑɱMÑÑ ÀÌØí1±|̰ÀÌØí¹Õ´¤(% ÍÀÌØíµÍôÀÌØíU%}Y9Q} 1=M($%á¥Ñ1½½À(% ͱÍ(%¹M±Ð)]¹)á¥
Xenobiologist Posted June 8, 2006 Posted June 8, 2006 (edited) Hi, did you test it? IMO it doesn't work because it counts letters twice. Hugo = 8 But if that is what you wanted, ... So long, Mega For me this works as I expected: #include <GuiConstants.au3> GUICreate("CharCount", 300, 200, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Edit_1 = GUICtrlCreateEdit("Input Text Here.", 0, 20, 300, 180) $Label_2 = GUICtrlCreateLabel("Total Chars: ", 0, 0, 60, 20) $Label_3 = GUICtrlCreateLabel("number", 70, 0, 120, 20) $Button_4 = GUICtrlCreateButton("Submit", 200, 0, 100, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_4 ;~ $file = FileOpen(@DesktopDir & "\Muzen.txt", 0) $string = GUICtrlRead($Edit_1) Local $array = StringSplit($string, "") $num = 0 For $i = 1 To UBound($array) - 1 If StringIsAlNum($array[$i]) Then $num += 1 EndIf Next GUICtrlSetData($Label_3, $num) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Edited June 8, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Moderators SmOke_N Posted June 8, 2006 Moderators Posted June 8, 2006 I agree with th.meger here... that doesn't make much sense... $StringLen = StringLen(FileRead('results.txt')) $FileSize = FileGetSize('results.txt') $StringSplit = StringSplit(FileRead('results.txt'), '') MsgBox(64, 'info', $StringLen & @CR & $FileSize & @CR & UBound($StringSplit) - 1)Here are some different ways that all came out the same result. 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.
Xenobiologist Posted June 8, 2006 Posted June 8, 2006 I agree with th.meger here... that doesn't make much sense...Thanks for supporting me this time. So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
gamepin126 Posted June 9, 2006 Author Posted June 9, 2006 (edited) The editbox maxes out at 23778 characters, why? I use t his to test it.http://www.fileupyours.com/files/34344/1to425090.txt (3mb) Edited June 9, 2006 by gamepin126
Xenobiologist Posted June 11, 2006 Posted June 11, 2006 HI, I can put 30,000 chars into it. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
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