Monique Posted October 11, 2013 Share Posted October 11, 2013 Hi, This is my first post on this forum. I've just installed Autoit and try to do some useful work Here is my problem. I got a text file "names.txt" with 1000 names and surnames. The file looks like this: Adam Smith Bryan Brown Cecil Alden ...... and the following 1000 names like these. What I need to do is to put all these 1000 names and surnames into a right box. Apart from this I have to create an email address out of each name and surname. An address should look like this: AdamSmith@blablabla.com So basically what I need to do is to remove the space character from between a name and a surname and add to the end of this string a constant string "@blablabla.com". I need to do just these two things. And I got still errors. Can you please check my code and tell me why? #include <File.au3> Const password = "blablabla1" Const email_suffix = "@blablabla.com" $file = "C:\Users\monique #1\Desktop\names.txt" $file2 = "C:\Users\monique #1\Desktop\email.txt" $name = "" $email = "" ;Step 0. The general loop Local $i = 1 While $i <= 1000 ;Step 1. Open a file, read a line and copy it to the "$name" variable FileOpen($file, 0) $name = FileReadLine($file, $i+1) Next FileClose($file) ;The "$name" variable should be now the first username (name and surname) from the file ;Step 2. Create an email address for a given username FileOpen($file2, 1) $email = FileWriteLine($file2, $name-"", $email_suffix) ;The "$email" variable should look now as the following: namesurname@blablabla.com ;which means the "name" and "surname" without a space character ;Step 3. Here goes the code which inserts variables: $name, $email and $password ; to the correct boxes and the loop may run again. I got this code and it works! So why I got errors? This is an easy code I guess and I still can't do it properly. Would be grateful for your suggestions. Monique Link to comment Share on other sites More sharing options...
UEZ Posted October 11, 2013 Share Posted October 11, 2013 What is the purpose of creating so much email addresses?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...
Monique Posted October 11, 2013 Author Share Posted October 11, 2013 What is the purpose of creating so much email addresses? Br, UEZ It's all for a blog project. We (me and my friends) want our blog to have at least 1000 users so we have to create them So we have created user names and one password and an email address in the same domain for every user. We don't want to do this manually that is why I found out about Autoit, downloaded it and decided to learn it Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 11, 2013 Moderators Share Posted October 11, 2013 So, you're creating a bunch of fake users to make it seem like your blog is worth reading?? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
FlashpointBlack Posted October 11, 2013 Share Posted October 11, 2013 (edited) The good thing about autoit is the help file is actually... helpful! This is a bit more complicated than it has to be, but it will give you a decent starting point into how to use autoit for other more complex things. There are definitely easier ways (actually with only a few lines) $LoadFile = "C:\NameList.txt" ; set the path to your file here $SaveFile = "C:\EmailList.txt" $Domain = "@blablabla.com" ; set the text to append to the end of the names $ArrNames = StringSplit(FileRead($LoadFile),@CRLF,1) ; this splits the text in the file into an array using a "return" keystroke as the splitter Local $WriteData ; declare a variable to use to store the prepared data for $i = 1 to $ArrNames[0] ; do the following code for each line in the file $WriteData &= StringStripWS($ArrNames[$i],8) & $Domain & @CRLF ; strips the part of the string read from the file (name) of all space characters, ; adds the domain and a "return". appends this data to the end of $WriteData next ; loops back to "for" $hWriteFile = FileOpen($SaveFile,2) ; prepares a new file to be written FileWrite($hWriteFile,$WriteData) ; write the data you've assembled to the new file FileClose($hWriteFile) ; close the file since we're done writing msgbox(0,"Complete","Operation has completed.") ; show a message box saying the operation completed successfully. If there's anything that doesn't make sense, look at the help file and look up the function for detailed information on how to use it along with examples. Edited October 11, 2013 by FlashpointBlack Link to comment Share on other sites More sharing options...
Monique Posted October 12, 2013 Author Share Posted October 12, 2013 Thank you very much. I used your code, change it slightly and expanded. Now it works perfect. Thanks again. 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