Jump to content
Macro Express Forums

Populating Multiple Choice Menu From Text File


msandford

Recommended Posts

Hello,

 

I've only done fairly simple macros with Macro Express so far, so forgive me if this is easier than I realize. Is there a way to populate the Multiple Choice Menu from a text file? I'm in an environment where several people use the same macro on different computers and would like the text file to live on a shared drive. It will need regular updating, and I don't want to have to go to every computer to make the changes.

 

Thanks,

 

Mark Sandford

Link to comment
Share on other sites

It is possible to do. You could do it with a comma separated file(csv). Once the file was created, you would use the ASCII File Process Begin command and then the ASCII File End Process. When you use the Multiple Choice Menu command, make sure that the Destination Variable is set to T99, or at least a variable that will not be used by the ASCII File commands. Instead of entering the actual data into the Multiple Choice Menu, enter %T1% for line A, %T2% for line B, and so on. The macro will look something like this below:

 

ASCII File Begin Process: "Multiple Choice.csv" (Comma Delimited Text )
ASCII File End Process
Multiple Choice Menu: Test

Link to comment
Share on other sites

It's way easier than that. Save the text file with carriage returns. IOW multiple lines. Like:

 

Tom

Dick

Harry

 

Now read that text file into a text variable like T1. Now in the multiple choice menu simply write %T1% on the first line. I know it seem odd but your multiple choice menu will now display all three choices! This way you only need one text variable.

 

In some macros I write I manipulate files or search for text. Each time I find a hit I can simply append an accumulator variable. You just need to add a CRLF (carriage return/line feed) to the end and now it's easy to display to your user for choice!

Link to comment
Share on other sites

Sorry Jason, I didn't intend to put down your response. That works too. I hope you didn't take offense, I intended none but I should have choose my words more carefully.

Link to comment
Share on other sites

I just want to add to Corys post. It's possble to paste or write

Tom

Dick

Harry

etc.

 

Into [Text Type] and choose [use Clipboard to Paste Text].

Then open [Variable Set String] and choose [set Value from Clipboard] and [Choose Variable Name] T1.

Last [Clipboard Empty].

 

Then the following as Cory discribed:

"Now read that text file into a text variable like T1. Now in the multiple choice menu simply write %T1% on the first line. I know it seem odd but your multiple choice menu will now display all three choices! This way you only need one text variable."

 

Still the problem is that you only could use 37 alternatives in the Menu list in Multiple Choice Menu. The possibility for more alternatives then 37 is something i wish for. Does anyone know if this has been brought up before?

Link to comment
Share on other sites

Since the Multiple Choice Menu assigns a key to each entry, it is limited to 36 items (A-Z and 0-9). We have considered expanding the number of possibilities perhaps by using lowercase letters. But that option would cause confusion for some users when someone typed 'a' instead of 'A'.

 

Another consideration is that as the number of items increases it takes the user longer to read through them to know what to pick. Our suggestion has been to create categories and when you click on an item it may bring up another Multiple Choice Menu.

Link to comment
Share on other sites

Simple. I have several macros that do something like search for results in large text files or directories on a file server that match a string so I need to account for the eventuality of more than 36 entries. Usually what I do it count the number or items returned and then I have a clever little loop-test that gives it to the user in chunks. First off I don’t use text files. I have this aversion disk writes to I pump all my matches into a single accumulating text var separated by something like a tab. So when I start out there may be 60 matches. Then I chew thru that var and count until the var is blank. Each time I write the text to a new string var that I will use in the multiple choice appending each with a CRLF. IF I get to 35 I append a “More…” to the end of it and display it to the user. If they choose more it continues chewing thru the original accumulator var, deleting entries as it goes. It’s pretty easy to do.

Link to comment
Share on other sites

Our thanks go out to Cory for documenting the ability to use a single variable to populate the Multiple Choice Menu. It is great to discover a simple solution to a complex problem.

Perhaps this method should be mentioned in the ME Help file.
I agree that this is a great technique. However, if we included every great tip in the help file it would be so large that no one would read it.

 

There are three places where tips and techniques are shared:

We will be featuring Cory's Multiple Choice Menu tip in a future edition of the Macro Express News email newsletter. We invite all forum members to contribute tips, techniques and macros. You could win a Macro Express T-shirt for your submission.

Link to comment
Share on other sites

I've come up with another method.

 

I create a text file

in it, I can list any amount of lines I wish (100+)

 

I have a macro that then opens this text file, and resizes it to about 100 x 200.

User can scroll down through text file, to item he desires

 

then, user clicks anywhere ON that item (beginning, end, middle, etc)

 

Right-clicking the mouse activates the next step of macro; it does

HOME (beginning of line)

Shift-END (goes to END of line)

COPY to clipboard

store in variable

 

you now have your selected item stored in a variable, able to place where you desire.

 

I don't have this macro clean enough to post, but it works pretty well to allow bypassing of the 36-entry limit of the multiple choice boxes.

Link to comment
Share on other sites

  • 3 months later...

Thanks, Aoz - your idea helped me with an issue I have had for a while, which is needing a multiple choice menu with project numbers that get added & deleted from the list over time. Your method makes it much easier to order my list alphabetically or numerically as my menu grows. I wouldn't have to re-renter all of my menu choices everytime I added or deleted an entry, I could just add it to my list where it needs to go.

Link to comment
Share on other sites

  • 3 months later...

Ok- I am totally unable to figure out what I am doing wrong.

 

I tried blopib's example of putting text in clipboard into a Variable and then using the variable in a multiple choice menu and it worked.

 

However, for the life of me, I can't get the process text/ascii file to do the same thing. It is not recognizing the line breaks and anything after the first record simply disappears.

 

I have been trying both process text file and ASCII file. I have tried comma and tab delimited, using a file exported from Excel and a text file created with notepad. Again, just copying the contents of these files into the clipboard and using the first example in this post worked. Processing the file automatically doesn't.

 

Please clue me in! :-) Thanks!

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...