Jump to content
Macro Express Forums

terrypin

Members
  • Content Count

    1,989
  • Joined

  • Last visited

  • Days Won

    15

terrypin last won the day on December 31 2019

terrypin had the most liked content!

Community Reputation

8 Neutral

1 Follower

About terrypin

  • Rank
    Master

Profile Information

  • Gender
    Male
  • Location
    East Grinstead, West Sussex, UK

Recent Profile Visitors

882 profile views
  1. Thanks Alan, I'll explore that interesting approach. Do you think can it be applied in the example under discussion?
  2. "I don't understand why you don't use the MEP file manipulation commands." I'm not sure I've understood. Apart from If File Exists, which I mentioned, what other 'file manipulation commands' do you suggest to handle file saving when OS messages are displayed as in my example? Or maybe you're referring to the simple way I've handled the file processing in that? IOW, are you instead recommending a Repeat with Folder to build a variable holding all files? If so, I agree, and if this was a larger project with many more files involved that's probably how I'd do it. But this was just a simplified example to focus on the subject issue. "I'd never type in file names..." Do you mean you don't use string variables to enter data as in my example? What advantage would using Controls offer? Wouldn't that involve more steps, and the same variable? "When I things that could have a popup error I use the existence of the controls." How would you do that for my example? What would be the target of the Get Control command, for instance?
  3. When running macros that save files they frequently fail because messages from the OS do not automatically pause the macro to allow user interaction before proceeding. A typical example: // Now re-open the file in F2 mode and enter the new name Text Type (Simulate Keystrokes): <F2> Delay: 0.1 seconds Text Type (Simulate Keystrokes): %tFilename% Delay: 0.1 seconds Text Type (Simulate Keystrokes): <ENTER> Delay: 0.1 seconds Text Type (Simulate Keystrokes): <ARROW DOWN> Delay: 0.1 seconds End Repeat After the ENTER command I might briefly see a message like "A file of this name already exists..." and be asked to choose a Yes or No option (e.g. to save with a suffixed name), but the macro continues regardless. Sometimes the fix is easy; for example when the message is asking whether to overwrite the previous file I can often safely insert a Text Type Y command. Or I can use If Window, specify 'Replace File', and add an appropriate action, such as a simple Pause. Or sometimes an If File Exists command is possible. But sometimes it's not so easy. What techniques do others use please? Terry, UK
  4. Let's see if a few others from various countries can join the discussion! I'm guessing it's a Windows OS setting?
  5. Yes. That's what prompted my surprise that our respective MEP versions are apparently 'localised'.
  6. Hi Alan, This command caused failure for me: Wait for Window Title: Color That has me fascinated, especially as I see that you personally spell 'colour' the same as I do! Is your version of MEP indeed AmericaniZed in that way? Using 6.1.3.1 here, and your macro works fine when I use the correct spelling 🙂 Terry
  7. Your original screenshot shows that your 1920 x 1080 screen was on that occasion not occupied by your maximised program. So that's a possible cause of earlier confusion about your Mouse Locator readings.
  8. Pleased to hear that's apparently fixed it.
  9. Didn't get a reply to my Friday post. Is your problem now resolved?
  10. Yes, that's easy enough. Exploring MEP's excellent Help you'll soon find several ways to do it. If you run into difficulty post again, but then please clarify what you are (always) doing at the point you will activate the macro. Looking at the HTML? In what application (browser, text editor, HTML app, etc)? Or with the file selected in its File Explorer folder? The same folder for every file, or varying folders? Also, as your comment suggests you may have many of these to process, think about using Repeat with Folder to convert all target files automatically. That's easy too but, although it might be fun for a while, it will slow down completion enormously.
  11. First, I assume you've now successfully run the macro? -------------------- Re your latest questions: To copy command text from the Script Editor: Select all > Right click > Copy Command Text To copy code from the Script Editor or Direct Editor: Select all > Ctrl+C Yes, it's just convenient to paste both commands and code into the Code box. Some of us do that and others open separate boxes. For a recipient, it's a matter of seconds to run a macro from its pasted code. Even faster than importing an MEX I'd think. And either method usually then requires editing to be sure the macro runs successfully in the recipient's environment.
  12. The fastest way to re-assign variables after pasting the code into a new macro is to simply hit Ctrl+s to start a Save. MEP will then prompt repeatedly as shown in my screenshot, and you then tap Enter (or Y) until finished. BTW, note that the six variables I've used are all text types and the three whose types might ever be ambiguous are all prefixed with 't'. I've also exported the file as an MEX. Use File > Import > Import Macros... and browse to the file to import it. It will usually be placed in the Unassigned category. Reassign the variables and Edit the file paths appropriately. Here's a 'Before and After'. Delete-HTML-Section.mex
  13. Using the method I outlined, this delivers the modified HTML in about one second, using your example file. // Set the EOL character for later use. Variable Set to ASCII Char 13 to %CR% // Set CR Variable Set to ASCII Char 10 to %LF% // Set LF Variable Set String %CRLF% to "%CR%%LF%" // Set the 'flag' to 'Retain', so that all such lines will be kept. Variable Set String %tAction% to "Retain" // Start Text Process; Get tLine for each line of HTML Text File Begin Process: C:\users\Test.html // Test for start of section If Variable %tLine% Contains "<section class="tsd-index-section ">" Variable Set String %tAction% to "Ignore" Goto:EndProcess Else // Not start of section // Test for end of selection If Variable %tLine% Contains "</section>" // End of section AND If Variable %tAction% Equals "Ignore" // End of section Variable Set String %tAction% to "Retain" Goto:EndProcess Else // Not end of section // Test if tAction = Retain If Variable %tAction% Equals "Retain" Goto:Add Else Goto:EndProcess End If End If End If :Add // Add this line to the output variable Variable Modify String %tOutput%: Append Text (%tLine%) // Also add an EOL. Variable Modify String %tOutput%: Append Text String Variable (%CRLF%) :EndProcess Text File End Process Text Box Display: Final Output // Disabled after testing // Save to new file Result.html in same folder. (Or immediately replace original if preferred.) Variable Modify String: Save %tOutput% to "C:\Users\Result.html" <COMMENT Value="Set the EOL character for later use."/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%" _COMMENT="Set CR"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%" _COMMENT="Set LF"/> <VARIABLE SET STRING Option="\x00" Destination="%CRLF%" Value="%CR%%LF%" NoEmbeddedVars="FALSE"/> <COMMENT Value="Set the 'flag' to 'Retain', so that all such lines will be kept."/> <VARIABLE SET STRING Option="\x00" Destination="%tAction%" Value="Retain" NoEmbeddedVars="FALSE"/> <COMMENT Value="Start Text Process; Get tLine for each line of HTML" _BACK="0080FFFF"/> <TEXT FILE BEGIN PROCESS Filename="C:\\users\\Test.html" Start_Record="1" Process_All="TRUE" Records="1" Variable="%tLine%"/> <COMMENT/> <COMMENT Value="Test for start of section"/> <IF VARIABLE Variable="%tLine%" Condition="\x06" Value="<section class=\"tsd-index-section \">" IgnoreCase="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%tAction%" Value="Ignore" NoEmbeddedVars="FALSE"/> <GOTO Name="EndProcess"/> <ELSE _COMMENT="Not start of section"/> <COMMENT Value="Test for end of selection"/> <IF VARIABLE Variable="%tLine%" Condition="\x06" Value="</section>" IgnoreCase="FALSE" _COMMENT="End of section"/> <AND/> <IF VARIABLE Variable="%tAction%" Condition="\x00" Value="Ignore" IgnoreCase="FALSE" _COMMENT="End of section"/> <VARIABLE SET STRING Option="\x00" Destination="%tAction%" Value="Retain" NoEmbeddedVars="FALSE"/> <GOTO Name="EndProcess"/> <ELSE _COMMENT="Not end of section"/> <COMMENT Value="Test if tAction = Retain"/> <IF VARIABLE Variable="%tAction%" Condition="\x00" Value="Retain" IgnoreCase="FALSE"/> <GOTO Name="Add"/> <ELSE/> <GOTO Name="EndProcess"/> <END IF/> <END IF/> <END IF/> <COMMENT/> <LABEL Name="Add"/> <COMMENT Value="Add this line to the output variable"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%tOutput%" Value="%tLine%" NoEmbeddedVars="FALSE"/> <COMMENT Value="Also add an EOL."/> <VARIABLE MODIFY STRING Option="\x07" Destination="%tOutput%" Variable="%CRLF%" NoEmbeddedVars="FALSE"/> <LABEL Name="EndProcess"/> <TEXT FILE END PROCESS/> <TEXT BOX DISPLAY Title="Final Output" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 %tOutput%\r\n\\par }\r\n" Left="502" Top="-1" Width="1243" Height="1175" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE" _COMMENT="Disabled after testing"/> <COMMENT Value="Save to new file Result.html in same folder.\r\n(Or immediately replace original if preferred.)"/> <VARIABLE MODIFY STRING Option="\x11" Destination="%tOutput%" Filename="C:\\Users\\Result.html" Strip="FALSE" NoEmbeddedVars="FALSE"/> <COMMENT/> <COMMENT/>
  14. So it is just that one section to be deleted, uniquely identified by its first line containing the string <section class="tsd-panel tsd-index-panel"> yes? If so one way would be to use Text File Begin Process. Test each line for that string. If it does not contain the string use Variable Modify String > Add Text to build an output variable. When it *is* encountered, skip the Add Text and instead set a flag. Test the flag for each subsequent line and if it is still set continue ignoring the Add Text command But also test for the string </section> and when found reset the flag. The remaining content will then be added to your output variable, which you will finally save to a file, replacing the original. Ah, I see acantor beat me to it, so try his complete macro first!
  15. Yes, sorry, I missed the fact that you were not using Pro. So you want to delete everything in that code block you've posted? If so, can you show us the surrounding content or the entire file?
×
×
  • Create New...