NeVeR Posted November 17, 2013 Report Share Posted November 17, 2013 I'm testing out something new and wanted to make random names. I have a list of 200 1st names and 200 surnames. I would want ME to randomly select a 1st name and sure name and store them in T1 and T2 -- and when repeated it would do the same but select 2 different ( random ) names from the list. There will be others parts to the macro.. but i can do them. Quote Link to comment Share on other sites More sharing options...
Cory Posted November 17, 2013 Report Share Posted November 17, 2013 I would put the names in an array and use the Variable Set Integer > Random Number and use that as an index pointer. No need to create T1 and T2 as you suggest. As an aside often people think they want random but in fact they want a quasi-random. For instance an MP3 player's random mode(AKA shuffle) isn't truly random. EG it will never play the same song back to back. With a true random it's possible. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted November 17, 2013 Author Report Share Posted November 17, 2013 not sure how that is done. I normally use ME3.. but the job just got my Pro.. and i'm still learning it. Quote Link to comment Share on other sites More sharing options...
NeVeR Posted November 17, 2013 Author Report Share Posted November 17, 2013 Also if I don't need T1 and T2 thing.. So can i tell my macro to type what I want.. when i want it ? The ideal thing would be something like this. Random name made. stored in T1 and T2 - ( I use these names to test sign up on our sites ) I have the macro programed to follow a set of steps.. and one of those steps is entering a username -- ( should is what the randomer makes )- -- and then at the end it would store these data in an excel sheet and then clear clipboard and start over.. and repeat. So I think i need it to store into in T1 and T2 Quote Link to comment Share on other sites More sharing options...
Cory Posted November 18, 2013 Report Share Posted November 18, 2013 Attached is a simple example. Random Name.mex Quote Link to comment Share on other sites More sharing options...
terrypin Posted November 19, 2013 Report Share Posted November 19, 2013 Here's a similar example which loads (populates) the array from a text file. // Populate the array of first names.Text File Begin Process: C:\TenNames1.txt Variable Modify Integer %nN%: Increment Variable Set String %tNames1[%nN%]% to "%tName1%"Text File End Process// Display 20 randomly chosen first names.Repeat Start (Repeat 20 times) Variable Set Integer %nRandom% to a random value between 1 and 10 Text Box Display:End Repeat The part that I found unintuitive when I started using arrays was getting the index into the array variable. The trick is to do it as I've shown here: BTW, note that I try to use the prefix 'n' for integer variables and 't' for text, following that discipline recommended by Paul some years ago. Coming from ME to ME Pro you'll probably have to wean yourself off the use of T[1}, N[2], etc, but I think you'll soon find that the meaningful filenames are very helpful. I'd be curious to hear a bit more about the application. Is it truly random or pseudo-random of some sort? The latter pose different (and probably harder) challenges. --Terry, East Grinstead, UK SelectRandomlyFromArray.mex TenNames1.txt 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.