Jump to content
Macro Express Forums

Advice Needed: Large Lookup/decode


Recommended Posts



I've been using Macro Express to automate some of my editing tasks, and I'd like your advice about whether it would be practical to use it in the following way.


I'm running a news site. Each day I post links to 60-70 news items originating in any of hundreds of sources. I spend a lot of time entering and re-entering things like "US-New York Times", "China-China Daily", etc. Since there are so many sources, it doesn't make sense to write (or remember) so many individual shortkeys.


It's occurred to me that, since I'm already using Macro Express to capture the URL for articles, I could construct a lookup table that would take something like...




...strip out the domain name...




...then look in a table for the "long form" name and type "Australia-ABC" into my edit window.


So, my question is this: would Macro Express be able to do something like that reasonably quickly if the lookup table had, say, 300-400 entries? By "reasonably quickly" I mean in about the same time it might take me to type it out manually?


Thanks for any thoughts you might like to share.

Link to comment
Share on other sites


Much quicker, I would imagine! - though I can't quite picture what you have to do!

? post a snippet of code if you need help?


Is the problem you are asking about;...

1. How to retrieve the domain name from the site name (or even from the site?).


2. how long it would take to look it up in the table?



3. what is the "long name" you are looking up; is it on the original site, or something you know beforehand to put in your table??

4. Are you actually opening that "html" site, or just using the name (you already have the html name you mentioned?)?


You can see I am not clear of what you need....


Best, Randall

Link to comment
Share on other sites

Sorry, I guess I didn't express it very clearly.


I'm using ME to grab certain information from, let's say, a New York Times article. I get the article title, a short selection of the article text, and the URL. Then I paste that information into a webform, clean it up as needed, and post it on my site. I've got ME macros already written that help with most of this.


One of the things I've been adding manually in the webform is a field called "Source". Until now, I've actually been typing out "US-New York Times" or whatever the source is for every item I post. That's the part I'd like to automate.


ME already has the URL (as one of the macros I'm already using), so I'd like first to strip it down to domain name only. That I can figure out without help.


Here's the part I do need help with:


I'd like to search a table for the domain name and have ME return the "long form" of the name. For instance, a simple example of the table might look something like this:


domain name            long form name
-----------            --------------
www.nytimes.com        US-New York Times
www.globeandmail.com   Canada-Globe and Mail
www.chinadaily.com     China-China Daily


ME would search the table for 'www.globeandmail.com' and then type "Canada-Globe and Mail" into my webform. The table would be quite extensive with potentially hundreds of domain name/long form name entries.


I'm not knowlegable enough about ME to know exactly how to do the table lookup thing. I'm guessing it could be a CASE statement:


if domain name = "www.nytimes.com"
then type text "US-New York Times"

elseif domain name ="www.globeandmail.com"
then type text "Canada-Globe and Mail"

elseif domain name ="www.chinadaily.com"
then type text "China-China Daily"


That's just pseudocode and I haven't tried to implement it yet using ME because my hunch is that it may not be terribly efficient once there are hundreds of CASE statements to evaluate. I'm sure there's a better way of doing this and would welcome any suggestions.


Hope I've made it a bit clearer... ;-)

Link to comment
Share on other sites

Just lost a long post ... AARRGGGHH! A message said the page expired and poof! it was gone. Okay, I'll be a little less wordy.


Writing this with Ifs or Switch/Case statements would be time consuming and difficult to maintain. I recommend this:


Create a comma separated values (.csv) file like this:

www.nytimes.com,US-New York Times
www.globeandmail.com,Canada-Globe and Mail
www.chinadaily.com,China-China Daily


Then use something like this macro snippet:

Variable Set String %T10% "China"

ASCII File Begin Process: "LookUpFile.csv" (Comma Delimited Text )
 If Variable %T1% contains variable %T10%
   Text Type: %T2%
 End If
ASCII File End Process


Look in the help file for more information about .csv files. I expect this would be a LOT quicker than typing the long form. But maybe you type faster than me. ;)

Link to comment
Share on other sites

  • 3 weeks later...

Just wanted to mention that I finally got around to this over the past few days. I ended up using a CSV file and the ASCII File Process command -- and it works perfectly! I am SO impressed! The table has only 68 rows right now, but the lookup feels instantaneous.


Thanks again for the pointers.

Link to comment
Share on other sites

Hello Cuppanews!


What you want to do is very simple. Just create a CSV file containing your lookups:


www.nytimes.com,US-New York Times

www.globeandmail.com,Canada-Globe and Mail

www.chinadaily.com,China-China Daily


Now whenever you want to use the long form of a name, use the following macro. Modify it to suit your system, of course:


// This is the domain to lookup.
Activate or Launch: "Notepad" OR "notepad.exe"
Variable Set String %T9% "www.globeandmail.com"

// Look it up.
ASCII File Begin Process: "long.csv" (Comma Delimited Text )
 If Variable %T1% = variable %T9%
 End If
ASCII File End Process

// Now type the long form out.
Text Type: %T2%

<REM2:This is the domain to lookup.><LAUNCHYES3:0:0112Notepad<LAUNCH:notepad.exe><TVAR2:09:01:www.globeandmail.com><REM2:><REM2:Look it up.><ADFBEG:F10:001:000001:000000:C:\Temp\long.csv><IFVAR2:4:01:1:T9T><BREAK><ENDIF><ADFEND><REM2:><REM2:Now type the long form out.><TEXTTYPE:%T2%>

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.

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.

  • Create New...