GSAK Macro to label all trails (With num of caches in trail)


Did I ever mention that I like cache trails? (Yes Cass, a HUNDRED times!) OK well, as I like trails so much and I’m playing around with GSAK at the moment I had a thought on how I could get myself a little macro to sort the data in GSAK into trails. I thought my prayers had been answered when I found this post on the macro list, but all that did was show me a list of trails in a pop-up box, it didn’t give me anything to sort my data with. So I decided to utilize the code from that one to make my own…

The code searches through the GSAK records and creates a new database, then performs SQL queries to look for cache names with x number of matching characters. I’ve got it set to 16 so it knows that if there are say 10 caches called “Wow what a really great trail” it matches “Wow what a reall” and finds all 10 and marks them as a trail. It also now does a reverse search, so if you have caches in a series named “#1 Great Caching Series”, “#2 Great Caching Series” it wouldn’t pick up from the front of the name, instead it matches “t Caching Series” at the end.

I added to this code so that it would insert these trail names into an array, then pick through each one and add the value the matching portion of the trail name to the ‘UserData2′ field, and the number of caches in that trail to the ‘UserData3′ field. Now I can sort all of my trails, and sort by the number of caches in each one. It also strips out any caches named ‘Sidetracked’ and ‘Church Micro’ as these aren’t trails, but are common names.

I thought I’d put it to the test and loaded in 1000 caches from Birmingham, 1000 from Worthing, 1000 from Bristol, 350 from Chelmsford, My finds from a few weeks ago (538), and 350 from Harlow, giving just over 3000 caches…

*Drum roll*

Well, it took at least about 10 mins to go through all the records. I don’t know if it’s just because of the amount of records, or if it just isn’t the most efficient code for the job, but the results are pretty darn good (If I do say so myself) I’m very pleased with it!

Not a bad result!

It’s never going to be perfect because it isn’t totally intelligent. For example, I have a large trail called “3SW”. This means I’d have to lower the matching number to 3 to grab this, however doing so would classify a load of other names as trails that aren’t trails. But on the whole, it catches most of the trails. This is definitely something I’m going to use to organize my caches, and hope it’s useful to others too. I think I need to add a nice interface, and look into some more efficient code, but on the whole I’m pretty pleased with my code! 🙂

The code is here:
CacheTrails

(As a side note, I used a website to convert my doc file to a PDF, it did it in a few seconds and I didn’t need to download anything! Cool! Had to upload a PDF as WordPress is limited as to what I can upload here)

Advertisements

6 Responses to “GSAK Macro to label all trails (With num of caches in trail)”

  1. GSAK Newbie – Massive Review and Tutorial « GeoCass UK GeoCaching Says:

    […] to do half what I wanted and built on it to create my own macro to add data to cache trails here. Don’t be scared of the macros, embrace them! You don’t get the opportunity to code […]

  2. Nick G. Saint Says:

    Hi, Cass.

    Do you have it tested in GSAK8?

    When I run your macro I’ve an error in line 63 : IF RegEx(Array(2,$loopCount), $d_Name )

    Error => TPerlRegEx.Compile() – Please specify a regular expression in RegEx first.

    Thank you in advance.

    Nick G. Saint

  3. Lonewolf_geocaching Says:

    Hi Cass,
    Great idea! However how do we install into GSAK ?

    Can’t find it in online macro index. Great tutorial on GSAK by the way but I don’t know what to do with the PDF file. I only use the macro index from inside GSAK. So a bit confused here.

    Kind Regards

    • geocass Says:

      I wouldn’t worry about it for now. Some other users have said that the macro doesn’t work in the latest versions of GSAK. I’ll have to get around to rewriting it!

  4. Paul Says:

    Hi Cass,

    Did you ever rewrite the code for this macro? Or have you found another Trial macro to use?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s