Jump to content
Macro Express Forums

Can ME select randomly from a list ?


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

 

MEPro-ArrayVariables-1.jpg

 

MEPro-ArrayVariables-2.jpg

 

 

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...