lastmember Posted March 26, 2013 Share Posted March 26, 2013 (edited) Hello!I have a text file containing FOLLOWINGjohn: 1234569ana: 55366696Johanson: 2536and I want to open it and make it look like this with - $file = FileOpen(@TempDir & "test.txt", 0):(file will have more lines)john : 1234569ana : 55366696Johanson : 2536how can I do that with AUTOIT?Thanks in advance! Edited March 26, 2013 by lastmember Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2013 Share Posted March 26, 2013 (edited) Look into StringRegExp, to get array of the data. Then loop through, with StringLen, to get the max len, and append spacing (to those shorter than max len) until it reaches the max stringlen. Edited March 26, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
UEZ Posted March 26, 2013 Share Posted March 26, 2013 What are the rules for the alignment? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
lastmember Posted March 26, 2013 Author Share Posted March 26, 2013 I am a beginner, you can post an example? Link to comment Share on other sites More sharing options...
lastmember Posted March 26, 2013 Author Share Posted March 26, 2013 (edited) : To be after the longest name[font=courier new,courier,monospace]john : 1234569 ana : 55366696 Johanson : 2536[/font] Edited March 26, 2013 by lastmember Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2013 Share Posted March 26, 2013 #include <Array.au3> $string = "john: 1234569" & @CRLF & _ "ana: 55366696" & @CRLF & _ "Johanson: 2536" $array = StringRegExp($string,"(.*)\:(.*)", 4) $iMaxLen = 0 For $i = 0 To UBound($array) - 1 $temp = $array[$i] ;~ _ArrayDisplay($temp) If StringLen($temp[1]) > $iMaxLen Then $iMaxLen = StringLen($temp[1]) Next $iMaxLen+=1 ; add the trailing space For $i = 0 To UBound($array) - 1 $temp = $array[$i] While StringLen($temp[1]) < $iMaxLen $temp[1] &= " " WEnd ConsoleWrite($temp[1] & ":" & $temp[2]) Next IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
lastmember Posted March 26, 2013 Author Share Posted March 26, 2013 thanks for promptly but I want to read from a text file and save it in another file, how to do that? Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2013 Share Posted March 26, 2013 (edited) Well, the variable is there for the string...what function should you call to read the text of a file? Look in the helpfile. File* or _File* functions Use the above function to populate the variable. Edited March 26, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
lastmember Posted March 27, 2013 Author Share Posted March 27, 2013 #include $file = FileOpen(@TempDir & "\test.txt", 0) $chars = FileRead($file) $array = StringRegExp($chars,"(.*)\:(.*)", 4) $iMaxLen = 0 For $i = 0 To UBound($array) - 1 $temp = $array[$i] ;~ _ArrayDisplay($temp) If StringLen($temp[1]) > $iMaxLen Then $iMaxLen = StringLen($temp[1]) Next $iMaxLen+=1 ; add the trailing space For $i = 0 To UBound($array) - 1 $temp = $array[$i] While StringLen($temp[1]) < $iMaxLen $temp[1] &= "." WEnd ConsoleWrite($temp[1] & $temp[2]) Next FileClose($file) YES IT IS OK ! merci beaucoup ! 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