terrypin Posted May 11, 2015 Report Share Posted May 11, 2015 I regularly play my son at Scrabble, online. He's championship standard so I have permission to cheat to avoid boring him. One tool I use is an anagram maker that (after some simple manual editing) gives me a sorted list like this in any text editor: AhoyAleAleAloeAloeAloeAltoAteAuto(etc) I want a macro to eliminate all repetitions, giving this: AhoyAleAloeAltoAteAuto(etc) I could of course do this with the working file open in my text editor. Which also appeals because it avoids even having to save the file. After all, I'm just pasting and sorting to view the words temporarily. Nevertheless I'd prefer the 'elegance' of using Text File Process instead. So I saved the document as Anagram.txt and compared each line to the previous, deleting it if identical. All easy stuff. But I have a mental block on how to re-display the file after the deletions! How do you edit the file itself as you step through each line? I'm thinking I'd probably be better off with the obvious, cruder method. With time zones in mind I'll probably solve this myself later today. But just in case anyone's around to give me a heads up please ... while I concentrate on my next move! --Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
terrypin Posted May 11, 2015 Author Report Share Posted May 11, 2015 Sorted thanks. It proved easy to get the result I wanted with a macro working in the text editor itself. I then discovered the way (well, one way) to do it using the neater and faster Text File Process method. I built a file from each line (after deleting duplicates), complete with CRLFs, and then finally saved that, replacing the original. --Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Cory Posted May 11, 2015 Report Share Posted May 11, 2015 I would read the file in as a string and split it into an array. Do my thing there by looping through the array. Then I would join it on CRLF and save that string to a file. BTW there are Scrabble cheat apps out there for your smartphone. Just enter all your tiles. Quote Link to comment Share on other sites More sharing options...
terrypin Posted May 11, 2015 Author Report Share Posted May 11, 2015 Thanks Cory. Haven't done much with arrays but I'll experiment. I hit a couple of snags with the macro I mentioned. Turned out it failed with more than two identical successive words. And sprinkled the result with empty lines. Obviously written too impatiently! I'll have a look for those apps, although that might take the cheating over acceptable limits! Quote Link to comment Share on other sites More sharing options...
rberq Posted May 11, 2015 Report Share Posted May 11, 2015 Once Anagram.txt is saved, read it and write Anagram_2.txt. Delete lines by NOT writing them to Anagram_2.txt. When Anagram_2.txt is complete, display it by calling Notepad with Anagram_2.txt as the parameter. Not fancy or especially elegant, but simple and should be plenty fast enough so your son won't fall asleep. Quote Link to comment Share on other sites More sharing options...
terrypin Posted May 12, 2015 Author Report Share Posted May 12, 2015 Thanks Bob. That approach worked fine, although I didn't need to use a second file. I TextTyped the de-duplicated version, built with Text File Process, over the original. Meanwhile, following up Cory's suggestion, I today found a cheat program that makes the macro entirely redundant! --Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.