t0ddie Posted January 14, 2009 Share Posted January 14, 2009 (edited) i want to split a string according to length. I want to split this string into an array of strings that are 128 characters or less each. Dim $aRecords $linelimit = 128 If Not _FileReadToArray("test.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] $line = StringLen($aRecords[$x] If $line > $linelimit Then $lines = StringSplit($aRecords[$x],heres the trouble area) endif Edited January 14, 2009 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
FireFox Posted January 14, 2009 Share Posted January 14, 2009 (edited) @t0ddie Perhaps this : (not tested) StringSplit($aRecords[$x], StringLeft($aRecords[$x], $line)) Edit : if the line lenght is 128 so you cant split it every 128 caracters, right ? $firstpart=StringLeft($aRecords[$x],128) $second = StringTrimLeft($aRecords[$x], 128) Cheers, FireFox. Edited January 14, 2009 by FireFox Link to comment Share on other sites More sharing options...
t0ddie Posted January 14, 2009 Author Share Posted January 14, 2009 @t0ddie Perhaps this : (not tested) StringSplit($aRecords[$x], StringLeft($aRecords[$x], $line)) Edit : if the line lenght is 128 so you cant split it every 128 caracters, right ? $firstpart=StringLeft($aRecords[$x],128) $second = StringTrimLeft($aRecords[$x], 128) Cheers, FireFox. i was thinking about that but it would be nice to have the functionality added to stringsplit. oh well, i guess it aint pretty but it should work. i will test Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
FireFox Posted January 14, 2009 Share Posted January 14, 2009 (edited) @t0ddie I think its possible to split with caracters but i dont know that for the moment $string = StringLeft($aRecords[$x], $line) While 1 $trim = StringTrimLeft($string, $line) If @error then exitloop MsgBox(64, "string split", $trim) $string = $trim WEnd Cheers, FireFox. Edited January 14, 2009 by FireFox Link to comment Share on other sites More sharing options...
weaponx Posted January 14, 2009 Share Posted January 14, 2009 You could try the first example for StringSplitRegExp. Link to comment Share on other sites More sharing options...
t0ddie Posted January 14, 2009 Author Share Posted January 14, 2009 (edited) i was thinking about that but it would be nice to have the functionality added to stringsplit.oh well, i guess it aint pretty but it should work.i will testactually I am running into all kinds of issues.like...i wont know in advance the length of the line, so i will need to create an arraythere must be a more simple way to do thissudden thoughtare wildcards supported for delimiters? Edited January 14, 2009 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Valuater Posted January 14, 2009 Share Posted January 14, 2009 (edited) here's a stab at it... #include <Array.au3> #include <File.au3> Dim $aRecords $linelimit = 128 If Not _FileReadToArray("test.txt", $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 To $aRecords[0] $line = StringLen($aRecords[$x]) If StringLen($line) > $linelimit Then While StringLen($line) > $linelimit $nline = StringLeft($aRecords[$x], $linelimit) _ArrayAdd($aRecords, $nline); or do something else??? $aRecords[$x] = StringTrimLeft($aRecords[$x], $linelimit) $line = StringLen($aRecords[$x]) WEnd EndIf Next *** NOT TESTED *** 8) Edited January 14, 2009 by Valuater Link to comment Share on other sites More sharing options...
FireFox Posted January 14, 2009 Share Posted January 14, 2009 @Valuater I dont know if my script or your script work but mine is smaller Cheers, FireFox. Link to comment Share on other sites More sharing options...
Valuater Posted January 14, 2009 Share Posted January 14, 2009 @ValuaterI dont know if my script or your script work but mine is smaller Cheers, FireFox.lol...I just tried to help "handle" the 128 chr string and keep it within the array ... But did this help????? no reply from t0ddie noted8) Link to comment Share on other sites More sharing options...
trancexx Posted January 14, 2009 Share Posted January 14, 2009 I've heard people saying: "Mine is bigger than yours!" You are weird ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 14, 2009 Moderators Share Posted January 14, 2009 lol...I just tried to help "handle" the 128 chr string and keep it within the array ... But did this help????? no reply from t0ddie noted8)You didn't really expect him to make sense and or reply with a thanks did you? 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. Link to comment Share on other sites More sharing options...
Valuater Posted January 14, 2009 Share Posted January 14, 2009 You didn't really expect him to make sense and or reply with a thanks did you?for sure...No!!!with as much as he knows about Autoit and with as many posts he has made, the OP example code has errors in it too!lol8) Link to comment Share on other sites More sharing options...
junkew Posted January 14, 2009 Share Posted January 14, 2009 size doesn't matter Simplified example splitting every 10th character (I leave the split function out of it but if real split needed split on CRLF) $myLine="012345678901234567890123456789012345" $myNewline=StringRegExpReplace($myLine, ".{1,10}", "$0" & @CRLF) consolewrite($myNewline) FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
t0ddie Posted January 15, 2009 Author Share Posted January 15, 2009 screw you, you assumptuous impatient bastards! I had to go to work. I am back now and will reply when I am good and damn ready. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 15, 2009 Moderators Share Posted January 15, 2009 (edited) screw you, you assumptuous impatient bastards!I had to go to work. I am back now and will reply when I am good and damn ready.Need a dictionary?Our "assumptions" are merely based on past facts. Edited January 15, 2009 by SmOke_N 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. Link to comment Share on other sites More sharing options...
t0ddie Posted January 16, 2009 Author Share Posted January 16, 2009 (edited) Need a dictionary? Our "assumptions" are merely based on past facts. I have always thanked the few people that help me here, and returned whatever bullshit has been thrown at me from the rest of the users. nothing has changed. thanks for helping guys, and as for the crude comments from the rest, blow me. I decided to use a loop instead of an array... this was my original unbuilt idea... but i thought it was unnecissary if i could find a better means... alas, it has been built. untested... but it should work. Dim $aRecords $linelimit = 128 $len = 0 If Not _FileReadToArray("murel_01.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] $len = StringLen($aRecords[$x]) If $len > $linelimit Then Do $bRecords = StringTrimRight($aRecords[$x],$len - $linelimit) $aRecords[$x] = StringTrimLeft($aRecords[$x],$linelimit) $len = StringLen($aRecords[$x]) ClipPut($bRecords) write() Until $len <= $linelimit Else ClipPut($aRecords[$x]) write() EndIf next I have had to do this type of thing before... just wanted a better way. -T0ddie Edited January 16, 2009 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
FireFox Posted January 16, 2009 Share Posted January 16, 2009 @Smoke_N sorry if there are errors in my script... if there is scite for ipod i will take it... what about for a page where you can write your code with colors and check for errors ? Cheers, FireFox. Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2009 Share Posted January 16, 2009 Need a dictionary? 8) Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2009 Developers Share Posted January 16, 2009 (edited) screw you, you assumptuous impatient bastards!I had to go to work. I am back now and will reply when I am good and damn ready.I am even more impatient with you!You better keep this attitude to yourself or better move on to another forum.* click * Edited January 16, 2009 by Jos 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...
Recommended Posts