Sign in to follow this  
Followers 0
unixu

howto sort my autoit output

9 posts in this topic

#1 ·  Posted (edited)

hi,

i got a small problem in sorting my autoit output

my output looks like this

"bildungsstufe",

"agi",

"def",

"att",

"def",

"agi"

i want to sort the output to something like this :

word1 word2 word3

word4 word5 word6

word7 word8 word9

instead of :

word1

word2

word3

a.s.o

is there a way to do that because the output is send to a gui.

Edited by unixu

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

i tried with a for function which schould do a linebreak every third word.

didn't worked out.

here is my example i tried but its not creating any files.

#include<string.au3>

$content = FileRead("test.txt")
$newline = StringSplit($content,",")


for $i=0 to UBound($newline[0]) -1
If $i == $newline[0]/$i Then
    FileWrite("newcontent.txt", $newline[$i] & @CRLF)
Else
    FileWrite("newcontent.txt", $newline[$i] & "    ")
EndIf
Next

content of test.txt is

att,
def,
att,
def,
agi,
att,
agi,
att,
Edited by unixu

Share this post


Link to post
Share on other sites

This statment is wrong

for $i=0 to UBound($newline[0]) -1

Should say..

for $i=0 to $newline[0]

Share this post


Link to post
Share on other sites

Also to quickly check if fileread() and Stringsplit() worked liked you expected you could use _Arraydisplay() to view the array.

#include<string.au3>  
#include<array.au3> 
$content = FileRead("test.txt") 
$newline = StringSplit($content,",")
_Arraydisplay($newline)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

dear beege my fileread worked as expected

edit: Dear 99ojo thx your example worked perfect for my needs :(

Edited by unixu

Share this post


Link to post
Share on other sites

Another example.

; Modified from
; http://www.autoitscript.com/forum/index.php?showtopic=101594&view=findpost&p=722113

Local $sStr = "att," & @CRLF & _
        "def," & @CRLF & _
        "att," & @CRLF & _
        "def," & @CRLF & _
        "agi," & @CRLF & _
        "att," & @CRLF & _
        "agi," & @CRLF & _
        "att,"
; OR
;Local $sStr = FileRead("test.txt")

MsgBox(0, 'Display 2D array style (Not an array)', _
        "From: " & @CRLF & $sStr & @CRLF & @CRLF & "Display 3 columns." & @CRLF & _
        " Result: " & @CRLF & _StringDisplayRE($sStr, 3, " ") & @CRLF)


Func _StringDisplayRE($sStr, $iNumOfCol = 0, $SpaceType = @TAB)
    Return StringRegExpReplace(StringRegExpReplace($sStr, "(.*[^\v])(?:\v+)", "${1}" & $SpaceType), _
            "((.*?" & $SpaceType & "){" & $iNumOfCol & "})", "${1}" & @CRLF)
EndFunc ;==>_StringDisplayRE

Share this post


Link to post
Share on other sites

This statment is wrong

for $i=0 to UBound($newline[0]) -1

Should say..

for $i=0 to $newline[0]

Or

for $i=0 to UBound($newline) -1

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!"

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0