Jump to content
Macro Express Forums

lemming

Members
  • Posts

    140
  • Joined

  • Last visited

Everything posted by lemming

  1. Installation guide for Insertion Sort demo 1. Download the sort scripts (.mex) from the Macro Express Forums, i.e. from this page. 2. Download the test data (.txt) from Macro Express Forums. Take note of the file location for later use. 3. Import the sort scripts from the downloaded .mex file into Macro Express Pro. Click File->Import->Import Macros… In this example, the file is Insertion Sort demo (strings) v 0.9.1 MEP.mex. Click Open. In the Import Macros window, click Select All and click OK. 4. You will now need to modify the scripts to work on your system. Basically, change the locations for the input and output files. In the Macro Express Pro Explorer window, double-click on the sort script to open it in the Script Editor window. Change the lines that start with “Variable Set String %SourceFile%” and “Variable Set String %ResultsFile%”. Just change the path to where the text source file is on your system. Click OK when you’re done and close the Script Editor window. 5. You can now run the script. There is no hotkey; just click on the script to select it, then click the “play” button in the Macro Express Pro Explorer window. Open “sorted listed.txt” to check the results. Other things to note: - The sorts are in ascending order (A to Z) - Hint for Win Vista/Win 7 users – don’t save input and output files to C:\ - The default input file is "Top xx movies.txt". Change as needed. - The default output file name is "sorted.txt". Change as needed. - Any existing output file with the same name is deleted every time the scripts are run. - There is very little error-handling - The array size must be known beforehand. I don't know how to assign it dynamically. To change the array size, go to Script Editor window->Variables->Text Variables - I haven't tested it with numbers (numerical sorting), but that should be trivial to implement. Insertion Sort demo (strings) v 0.9.1 MEP.mex Top 100 movies.txt Top 250 movies.txt Top 500 movies.txt Top 1000 movies.txt
  2. Building on my previous Bubble Sort and Gnome Sort scripts, here is my implementation of Insertion Sort. Like the previous scripts, this is a "pure" macro - no external programs, scripts or libraries are used. However, it will only work with Macro Express Pro, because it need arrays. Insertion sort outperforms both Bubble Sort and Gnome sort, as predicted by complexity analysis. http://en.wikipedia.org/wiki/Sorting_algorithm This implementation is based on my understanding of the Insertion Sort algorithm, as explained by xoaxdotnet - http://xoax.net/comp/sci/algorithms/Lesson2.php Other references: http://en.wikipedia.org/wiki/Insertion_sort Benchmarks on an old machine running Win XP (P4 3GHz Northwood, about 5 years old): Insertion Sort 100 elements = about 0.6 sec 250 elements = about 3.5 sec 500 elements = about 14.8 sec Bubble Sort 100 elements = about 1.0 sec 250 elements = about 5.7 sec 500 elements = about 24.7 sec Gnome Sort 100 elements = about 1.2 sec 250 elements = about 6.6 sec 500 elements = about 30.3 sec Downloads and installation guide are in the next posting. -Lemming
  3. The key new feature in MEP is the arrays. It's very difficult to implement sorting without arrays. I actually did write a bubble sort for ME a few years ago. It was very hard to understand and maintain. Heck, even I don't know how it works now. I consider it deprecated. As for the company you're contracting for - do all the users need sorting code? If not, just upgrade a few of them at a time. -Lemming.
  4. 1. Download the sort scripts (.mex) from the Macro Express Forums, i.e. from this page. 2. Download the test data (.txt) from Macro Express Forums. Take note of the file location for later use. 3. Import the sort scripts from the downloaded .mex file into Macro Express Pro. Click File->Import->Import Macros… In this example, the file is Bubble Sort demo (strings) v 0.9.1 MEP.mex. Click Open. In the Import Macros window, click Select All and click OK. 4. You will now need to modify the scripts to work on your system. Basically, change the locations for the input and output files. In the Macro Express Pro Explorer window, double-click on the sort script to open it in the Script Editor window. Change the lines that start with “Variable Set String %SourceFile%” and “Variable Set String %ResourceFile%”. Just change the path to where the text source file is on your system. Click OK when you’re done and close the Script Editor window. 5. You can now run the script. There is no hotkey; just click on the script to select it, then click the “play” button in the Macro Express Pro Explorer window. Open “sorted listed.txt” to check the results. Other things to note: - The sorts are in ascending order (A to Z) - Hint for Win Vista/Win 7 users – don’t save input and output files to C:\ - The default input file is "Top xx movies.txt". Change as needed. - The default output file name is "sorted.txt". Change as needed. - Any existing output file with the same name is deleted every time the scripts are run. - There is very little error-handling - The array size must be known beforehand. I don't know how to assign it dynamically. To change the array size, go to Script Editor window->Variables->Text Variables - I haven't tested it with numbers (numerical sorting), but that should be trivial to implement. Gnome Sort demo (strings) v 0.9.1 MEP.mex Bubble Sort demo (strings) v 0.9.1 MEP.mex Top 500 movies.txt Top 100 movies.txt Top 250 movies.txt
  5. This seems like a rather roundabout way to solve the problem. Do you know who creates the PDFs? Can you influence the workflow? Why not just configure Acrobat (or whatever) to spit out standard PDF files? -Lemming
  6. Hi David et al, I am tweaking the scripts and will post updated versions soon, with a step-by-step installation guide. Stay tuned! BTW, the password dialog is probably from Windows Vista or Windows 7; my code does not include passwords. Also, these script need Macro Express Pro. -Lemming
  7. Alan, you can use a Repeat Start with "number of times to repeat" set to the value which you consider to be too high. Then, within the loop, you can break out of it by using a Repeat Exit command set to the condition you are looking for.
  8. Make sure you have the data file in the right place, and its filename is correct.
  9. Yeah, I would second the addition of regex support. A search-n-replace operation that needs dozens of lines of code can often be distilled into a single regular expression. Macro Express developers, might I suggest PCRE - Perl Compatible Regular Expressions, a free library that is widely used to add regex support. Terry, in the meantime, you might want to check out: GREP Command for Windows XP http://malektips.com/xp_dos_0011.html UPDATE: Here's a direct link to the Windows Server 2003 Resource Kit Tools which includes Qgrep.exe. http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&DisplayLang=en The download is about 12MB but you really only need Qgrep.exe which is located in C:\Program Files\Windows Resource Kits\Tools
  10. Thanks for the tip, Paul. It works now. Turns out I was missing some punctuation. I updated my code and got a slight performance boost.
  11. Other input files for testing. Also, a few webpages I refered to: Gnome Sort (Wikipedia) http://en.wikipedia.org/wiki/Gnome_sort Bubble Sort (Wikipedia) http://en.wikipedia.org/wiki/Bubble_sort Visualization of Quick sort IMDB Top 10.txt IMDB Top 50.txt IMDB Top 100.txt Top 500 Girl\'s names 2009.txt
  12. Here's not one, but two sort algorithms implemented in MEP. The first is the classic Bubble Sort algorithm, while the second is Gnome Sort, described as "the simplest sort algorithm". These are "pure" macros - no external programs, scripts or libraries are used. I didn't even use dynamic variables! (i.e. Run Macro in Variable). However, they only work with MEP, because they both need arrays. These scripts' performance are better than my old ME3 Bubble Sort script, but they're still slow - many orders of magnitude slower than the built-in sorting functions available in other programming languages and script languages. UPDATE 1: I cleaned up the code a bit and added more comments. Thanks, Paul. Pls delete any ver 0.8 files you have, and download the latest. UPDATE 2: Tweaked the code for better performance, updated benchmarks and added an installation guide. Pls download the latest files below and delete old versions. Benchmarks on an old machine running Win XP (P4 3GHz Northwood, about 5 years old): Bubble Sort 100 elements = about 1.0 sec 250 elements = about 5.7 sec 500 elements = about 24.7 sec Gnome Sort 100 elements = about 1.2 sec 250 elements = about 6.6 sec 500 elements = about 30.3 sec You can easily conduct your own benchmarking because I've included code for reporting the start and end time. Comments are appreciated. Regards, Lemming
  13. Hi Cory, thanks for the tip. It works great. I got the array populated as needed. Paul: I might try "Text File Process" again for another project. For now, I will use the Split command. Thanks. -Lemming
  14. Hi, am just returning to Macex after a long absence. Many new features! I'm happy to see the addition of arrays, but I can't seem to get them to work. I have a list of IMDB Top 250 films in a text file (attached). One movie per line. How do I get Macex Pro to parse the file and stick each movie into a separate element? e.g. movie[1] = The Shawshank Redemption (1994) movie[2] = The Godfather: Part II (1974) movie[3] = Il buono, il brutto, il cattivo. (1966) and so on... I did try the "TEXT FILE BEGIN" command, but all I get is a single variable (movie[1]) filled with the last movie on the list. Regards, Lemming IMDB Top 250.txt
  15. LOL. I actually did write a bubble sort macro for Macex ver 3.5x a few years ago http://pgmacros.invisionzone.com/index.php?showtopic=918 It wasn't fast, but I suspect it was because I had to create an array for ver 3.5x. http://pgmacros.invisionzone.com/index.php...9&hl=bubble I have not tried Macex Pro, and in fact, I no longer use Macex. So perhaps someone else could rewrite it to use the new arrays supported by Macex Pro. I'm sure it'd work a lot faster than my macro, which used a kludgy array.
  16. Backing up and restoring Outlook is a fairly elaborate process. In fact, there are programs designed just for that. For a step-by-step guide refer to his MS page: How to manage .pst files in Outlook 2007, 2003, and 2002 And a related page for Outlook Express: How to back up and to restore Outlook Express data
  17. It's probably Windows locking the file. You may be writing to it too many times, or trying to append too fast within a short period. I'd suggest reducing your "Append to Text File" commands. Instead of writing to file every single time, you could append data to a variable first (Append Text String Variable), then later write it to file after say, 10 lines.
  18. If you don't mind a slight delay, you could get by with a scheduled macro using the If Window Running and If Program Not Running commands: something like: If Not Program Name "FIREFOX.EXE" running If Window Title "Some window that needs closing" is running Window Close: "Some window that needs closing" End If End If Then set the macro to run every 15 seconds or so. Note that Macex is "single-tasking" though, so you can only run one macro at a time. That means when this macro is running, other macros cannot run, and vice versa.
  19. It is likely that the emulator has installed its own keyboard hook after Macex, which means it will intercept keystrokes before Macex. You can try Macex's Restore Keyboard and Mouse Hooks command after the emulator has loaded. This is accessible by right-clicking on the Macex icon in the tray.
  20. I thought this would be easy, but apparently not. I came up with a rather crude way to implement this. It just uses a loop which presents a list of choices for the required number of selections (5, in this example). Each time you make a selection, it is appended to a text variable, T2. The text box called "Variable update" is just for your information and it provides a real-time update of what you have selected. It is not actually needed for the macro to run. On the plus side, this method allows you to select the same item multiple times, and it can also accept an arbritary number of selections, even if they are less than the maximum set. In this example, you could just select 3 names and click Cancel, and the macro will present what you have selected so far. In either case, the final selections will be in the T2 variable, separated by commas. If you need to further assign the selections to separate variables, you can first save T2 to a text file, then use the Process an ASCII Delimited Text File commands to complete the task. Repeat Start (Repeat 5 times) Text Box Display: Variable update Multiple Choice Menu: Test multi-pick If Variable %T1% = "CANCEL" Break End If Variable Modify String: Append %T1% to %T2% Variable Modify String: Append "," to %T2% Text Box Close: Variable update Repeat End Text Box Display: Selection complete For the complete code, download and import the file below. multi_pick_remember_order.mex
  21. Whoops, my bad. I had always thought variables had to be saved for passing to another macro. Looks like I'll need to rewrite some of my macros. Perhaps the documentation could clarify this in the future. From reading the helpfile, I got the impression these steps were mandatory.
  22. CORRECT INFO IN POST BELOW * Thanks, Jason. Looks like you're using the Macro Run command. Macex variables are not global, so running another macro will result in it having empty variables (reset to zero). You will need to use the Variable Save command to save and restore variables between macros. So, assuming Macro A calls Macro B, you need to: 1) Save variables in Macro A just before calling Macro B. 2) Call Macro B, and when in Macro B, restore variables. To return data to Macro A, you have to reverse the process. This is one of the weaknesses in Macex.
  23. I am absolutely against any form of GOTO which will inevitably lead to bad coding habits and Spaghetti code. I think it is a really bad idea which will come back to haunt Insight Software. These forums will soon be filled with questions like, "why doesn't my spaghetti code work?" and "can you help me sort thru this spaghetti?". Plus you would not be able to remove the feature without breaking scripts. It would be much better to implement procedural (structured) programming, in particular Subroutines, which are also called functions or procuderes. In the meantime we have the Macro Run command (as mentioned above), but it is a poor substitute mainly because it take extra effort to pass variables between macros. We could also do with more advanced data structures, like named variables (instead of T1, T2, etc) and arrays (which I have implemented, BTW, at great complexity). Macex has the potential of being a really good scripting language and with a few more improvements, it can be seen as a real programming language.
  24. Sorry to have to disagree with you Joe, but that is such an 80's mentality. Making secret plans and not listening to users is a recipe for disaster. I hate to have to mention other products, but AutoHotkey (ahk) is a really formidable competitor to Macex, and it is open-source and free. One thing I really like about the product is that it has very active forum, which among other things has sections for wishlists, bug reports, and upcoming features. Plus, the ahk author himself reads and posts on the forums. In fact, I have already ported about a quarter of my Macex macros to ahk, simply because I have no clear indication of whether certain features will be implemented in Macex, or even if the company has any idea about what its competitors are offering. Don't worry though, I'll still contribute to this forum.
  25. Yes, that would be useful. I sometimes shuttle macros between work and home, and I have a hard time keeping track of which have been modified. Right now, any imported macros are set to the current system time/date.
×
×
  • Create New...