Pain Posted April 28, 2008 Share Posted April 28, 2008 ok i'm stuck here. I got a big txt file with alot of words in and some of the words are in UPPERCASE. I've been trying the whole day with StringLower and Upper but failed, also tried with Asc but I didn't really understood how it worked (well I know it return the ascii code and then I should add 32 to get the lowercase but couldn't get it to work for my words). I don't got much of script to post (since all failed) except a example of how it should work. let's say the file looks like this: HELLO This is A TeSt and I want it to look like this: hello this is a test Link to comment Share on other sites More sharing options...
weaponx Posted April 28, 2008 Share Posted April 28, 2008 Whats the problem? You should use _FileReadToArray to get the contents, then For...Next to loop through every element. $var = StringLower($var) Link to comment Share on other sites More sharing options...
GunsAndRoses Posted April 28, 2008 Share Posted April 28, 2008 (edited) #include <File.au3> Local $TxtFile="file.txt" Dim $Lines _FileReadToArray($TxtFile, $Lines) FileDelete($TxtFile) $_Hn = FileOpen($TxtFile, 1) For $i=1 To $Lines[0] $Low = StringLower($Lines[$i]) FileWrite($_Hn, $Low&@CRLF) Next FileClose($_Hn) Maybe that'll help ya! Edited April 28, 2008 by GunsAndRoses Link to comment Share on other sites More sharing options...
Developers Jos Posted April 28, 2008 Developers Share Posted April 28, 2008 Hey G&R, you are back swiftly .... 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...
GunsAndRoses Posted April 28, 2008 Share Posted April 28, 2008 What? I dont understand. Link to comment Share on other sites More sharing options...
Pain Posted April 28, 2008 Author Share Posted April 28, 2008 (edited) thanx for the reply, now I finally got another step forward this is what I got this far. I took some of the code from another script I had since I'm not that familiar with array and things like that but I hope most it will work anyways. it will hopefully also be easier for you to understand what I'm trying to achieve. expandcollapse popup#include <File.au3> Dim $file = "test.txt" Dim $countlines Dim $line[1] Dim $i Dim $var Dim $testLine Dim $replace Dim $save $countlines = _FileCountLines($file) If $countlines <> 0 Then ReDim $line[$countlines] Else MsgBox(0,"","ERROR") Exit EndIf $fileRead = _FileReadToArray ($file, $save) For $i = 1 To $countlines Step 1 $line[$i - 1] = FileReadLine($fileRead,$i) Next FileClose($fileRead) For $i = 0 To UBound($line) - 1 Step 1 $testLine = $line[$i] For $var = $i + 1 To UBound($line) - 1 Step 1 If $line[$var] = StringLower($line) Then $line[$var] = "" EndIf Next Next ;write the new edited text into the file $fileRead = FileOpen($file,2) For $i = 0 To UBound($line) - 1 Step 1 If $line[$i] <> "" Then $replace &= $line[$i] & @CRLF EndIf Next FileWrite($fileRead,$replace) FileClose($fileRead) MsgBox (0, "", "Completed!") Exit Edited April 28, 2008 by Pain Link to comment Share on other sites More sharing options...
GunsAndRoses Posted April 28, 2008 Share Posted April 28, 2008 Just think of it this way. Arrays are just 1 variable, holding multiple information. Most AutoIt functions that use variables, are using $Variable[0] to tell how you much information is in this array. So then the best thing to do is to use a For/Next loop to parse the data you have collected like this: (Non-working code, just an example) _FileReadToArray($file, $array) ;Now you check parse the data. For $i=1 To $Array[0]; this is saying, from the number 1, to $array[0] which is a number holding how much information is in the array MsgBox(0, "", $Array[$i]); because this is an array, when looking for the data in the specifided line, you must use: $Array[$i]. This is saying that your looking at the Array item, with $i, which is how many times you have passed through the loop. Hope this helps you in understanding Arrays! Link to comment Share on other sites More sharing options...
Pain Posted April 28, 2008 Author Share Posted April 28, 2008 thanx for the help, array wasn't that complicated after all as I thought. I have now managed to debug my script with _arraydisplay to see what's wrong and from what I can see it was nothing wrong with my array so it's my cursed loops I've never liked loops and when I use loops I always use While. well, I will see if I can look closer to it tomorrow and maybe fix it but for the moment I got to go. Link to comment Share on other sites More sharing options...
GunsAndRoses Posted April 28, 2008 Share Posted April 28, 2008 Good Luck! And hope you get arrays down! Link to comment Share on other sites More sharing options...
Pain Posted April 29, 2008 Author Share Posted April 29, 2008 I found a easier way to do it. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Lowercase", 365, 566, 289, 173) GUICtrlCreateLabel ("Copy your text in here and it will be generated into lowercase." & @CRLF & "Press Copy to write the text to the clipboard", 40,5) $clear = GUICtrlCreateButton ("Clear", 200, 520, 113, 33,0) $Button1 = GUICtrlCreateButton("Copy", 50, 520, 113, 33, 0) $Edit1 = GUICtrlCreateEdit("", 40, 40, 281, 457, $ES_AUTOVSCROLL + $ES_LOWERCASE + $ES_WANTRETURN + $WS_VSCROLL + $WS_HSCROLL + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL ) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 copy() Case $clear clear() EndSwitch WEnd Func copy() $read = GUICtrlRead ($edit1) ClipPut ( $read ) EndFunc Func clear() $findall = GUICtrlRead ($edit1) GUICtrlSetData (-1, "") EndFunc it's working great for small files, however I got some files with more then 24 000 lines so my question is does autoit have any limit on lines? because I can only find Maximum string length and things like that in the help file. I tried to paste 100 lines at a time and it worked on line 9900 but when I pasted the next 100 lines (total 10 000) I couldn't paste anymore or write anything. the only thing I can think about is the Control Styles that I added, I took all default and added $ES_LOWERCASE since I didn't got time to try them all but without the default I could only type until the editbox was full (no scroll etc) Link to comment Share on other sites More sharing options...
Pain Posted April 30, 2008 Author Share Posted April 30, 2008 bump, no one that ever had this problem or know how to fix it? Link to comment Share on other sites More sharing options...
weaponx Posted April 30, 2008 Share Posted April 30, 2008 I wouldn't depend on an edit control to handle that much. Instead you should write a script that uses FileOpenDialog or drag and drop support so you can choose and existing file to convert. 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