t0ddie Posted September 27, 2004 Share Posted September 27, 2004 hello. im trying to take random size lines, and erase certain parts from it. i have a .txt document with this. **: k2#ldk, coolness **: Skf%6rk, ahah4haa **: ppppp, bo)g and i want to make it look like this. k2#ldk coolness Skf%6rk ahah4haa ppppp bo)g this list is constantly being added to.. and the size of each line is random. otherwise i would use string replace. stringtrim. i look a few things up. plus, i want to keep the space after the comma, but not the space after the colon: im pretty sure this is do-able, but i dont even know where to START. thanks for readin! ~Todd 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...
JSThePatriot Posted September 27, 2004 Share Posted September 27, 2004 Hey t0ddie... I am assuming the **: indicates a screen name of some sort? Because if it isnt then this is simple. You just trim the left side. Otherwise we have a slightly bigger problem, but I am sure you can do it as well. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
this-is-me Posted September 27, 2004 Share Posted September 27, 2004 Umm, Have you tried StringReplace($str, ", ", " ") ? or maybe StringTrimLeft($str, StringInStr($str, ": ") + 1) ? Who else would I be? Link to comment Share on other sites More sharing options...
t0ddie Posted September 27, 2004 Author Share Posted September 27, 2004 yes i tried all of those. and **: doesnt mean anything. that whole asterisk asterisk colon space can go. thats the easy part. just trim 4 from the left. the problem lies here... k2#ldk, coolness.. o wait, thats not a problem at all! (I JUST HAD A BRAIN FART) just string replace "," with "" i cant beleive how easy that is.. and that i didnt catch that before. thanks for leading me in the right direction. i figured it out! without even sample code! before the problem was.. because i didnt know how long each string is.. on either side of the comma and space.. because it is a different size every time.. i was confuzzled but yeah. you all are AWESOME. thanks for the quick reply! 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...
t0ddie Posted September 27, 2004 Author Share Posted September 27, 2004 heres the code, untested.. but im confident that it will work StringTrimLeft($bak,4) StringReplace($bak,",","",,) other than that... slightly off topic. has anyone written a script that will match each line in a file... and erase copies of the same line? so if this came up hjhjh hhjhjhjh fun fool sdjikpodsf sdfjhklhsdf jhqerlwerlolhiwe fun fool werujhiose heo it would look like this hjhjh hhjhjhjh fun fool sdjikpodsf sdfjhklhsdf jhqerlwerlolhiwe werujhiose heo thanks! 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...
mcfr1es Posted September 27, 2004 Share Posted September 27, 2004 hey toddie, I have written a script ( with the help of these people in the forum) that constantly adds usernames to a txt file but first checks if it alreadyy exists before adding... I'm on a public computer right now so i think ill post when i get home. In the mean time, try it a bit yourself, thats how you learn. This should get you started: try reading the list into an array to start with and continue to add it in that array as you go along (Ubound is key in this script) then write it in the txt file as well. As you are adding new values, check that new item against the whole array. this of course involves the use of a loop. Within the loop make a counter that counts how many times the new item is different from the old items. If the counter is equal to the number of items at the end of the loop (does not already exist) add it in the array (ReDIm) and the txt file as well and loop it! hope it helped, iwill post my script later but i find you understand better if you try it yourself first -Fryboy Roger! You son of a big pile o' Monkey Nuts. Link to comment Share on other sites More sharing options...
t0ddie Posted September 27, 2004 Author Share Posted September 27, 2004 makes sense. i look forward to your posting thanks. that was insightful. 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...
t0ddie Posted September 27, 2004 Author Share Posted September 27, 2004 well, i got it to work, had to change it slightly $bak = ClipGet() $bak = StringTrimLeft($bak,4) $bak = StringReplace($bak,",","") $file = FileOpen("TEST.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf thats her. isnt she pretty? not that its a huge deal.... but with an empty .txt file.. it wont write to the first line. what i mean is... that when the .txt file is empty, it will make a "blank" line (empty) (looks like a carriage return was performed first) before printing the line. it always starts on the second line. i can put some text in the first line, and that doesnt effect it. it still starts on the second line, like it should.. but not on the third line like i would expect because of the previous mentioned circumstance. so i dont know what the deal is. it only does this if the .txt file is EMPTY every other line writes fine.. with no "blank" lines between lines. just the first line always is blank. just thought that was interesting.. and was wondering if there is a reason for it? or if i found a bug? or if my coding is messed up? (usually is) well, have a look at it if ya want fellas. ~Todd 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...
Valik Posted September 28, 2004 Share Posted September 28, 2004 You do realize that:You never write to the file, you only open it for appending.You never close the file handle when you are done with it (Unrelated, but still something you should do). Link to comment Share on other sites More sharing options...
t0ddie Posted September 28, 2004 Author Share Posted September 28, 2004 actually i do both.. i just didnt include that part of the script in this post. but good looking out! ~Todd 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...
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