acantor Posted June 4, 2020 Report Share Posted June 4, 2020 Here is another Macro Express challenge: Can you write a script to automate the process of writing HTML code? A hypertext link on a website looks something like this: Welcome to the ABC 123 website The words are underlined. Clicking the link will take you to a website, for example: https://www.abc123.com The HTML code that produces a hypertext link on a webpage is this: <a href="https://www.abc123.com">Welcome to the ABC 123 website</a> Create a Macro Express script that analyzes data in two locations: 1. The clipboard 2. The selection (i.e., whatever text is selected) The script tests the clipboard to decide whether it is a web address or "ordinary text." The script also tests the selection to decide whether it is a web address or "ordinary text." (The rules for deciding whether text is a web address or ordinary text need not be foolproof, but they should work most of the time!) Once decided, the script outputs code for an HTML hypertext link: <a href="WEB_ADDRESS">ORDINARY_TEXT</a> If nothing is selected, the script applies the rules to the clipboard to decide whether it's a web address or ordinary text. If it's a web address, the script outputs: <a href="WEB_ADDRESS"></a> If it's ordinary text, the script outputs: <a href="">ORDINARY_TEXT</a> If both the clipboard and selection are empty, the script outputs: <a href=""></a> I first developed a Macro Express script to do this a decade ago, but the code was challenging to maintain and even harder to understand. It looked like a plate of spaghetti! Recently, I totally rewrote the script to make it easy (or at least easier!) to understand. How would you tackle this problem using only Macro Express? The goal is clarity! I'll post my solution here after others have chimed in. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.