This probably means nothing to most and is clumsy to a very few. But it works. And a more efficient method was sent to me that does not always work...
What follows is relevant to a piece of software called NoteTab Light. I have used it for years. every fortnight I make a webpage that I append to another webpage and upload to my website. It contains links to webpages that are labelled and described. The Pure Text editor will save a pure text document to HTML with paragraph tags and other essential code, within a template the user can make (as I have). But the links are simply as they were. You could copy, paste into the URL browser area and activate them that way. But as we all know, we click on links.
Many a Rich Text Format editor (it allows some formatting like bold and italic, a pure text file does not) will display links as active, but only a very convert to HTML with active links. Copywriter is one, but does not recognise https:// because it is old software. Other big Word Processers (with complex formatting) will not activate links until RETURN is pressed, and then saving to HTML produces ridiculously user-unfriendly complicated and repetitive code.
NoteTab Light has clips to do more with both flat text files and the HTML files (and XML). And I have written one that works and with one press activates all links in a file. And here it is:
^!SetScreenUpdate Off
^!ClearVariables
^!Jump Doc_Start
:Loop1
^!Find "http://" S
^!IfError END1
^!MoveCursor 1
^!Select Url
^!Set %url%=^$GetSelection$
^!InsertHTML ^%url%
^!Goto Loop1
:END1
^!Jump Doc_Start
^!ClearVariables
:Loop2
^!Find "https://" S
^!IfError END2
^!MoveCursor 1
^!Select Url
^!Set %url%=^$GetSelection$
^!InsertHTML ^%url%
^!Goto Loop2
:END2
^!SetScreenUpdate On
It depends on the very useful ^!Select URL, because it grabs the URL - although moving the cursor by 1 just makes sure you are on it rather than to its left. I like to make sure, so I have two loops so to include the https and the http. Each loop means the same instruction happens as the finding goes down the document and the 'error' is when there are no more URLs left to find. I am told I could use a ? for the s or no s in https and thus have one loop but I have not seen this ? in the help file. The screen writing is switched off so it is quicker. S also means a silent Find - no messages. I think screen updating comes on automatically at the end, but I like to be sure.
It's not my skill, such code writing, but I can see enough how others do it to put something together to achieve something else.
No comments:
Post a Comment