GSAK (Geocaching Swiss Army Knife)
Contents - Index

GsCodeToNum (function)

GsCodeToNum(sCode) : string

Groundspeak provide 2 unique Identifiers for a cache and they are closely related. Firstly there is the GCXXXXX code and secondly there is the ID number. There are times when you need the ID number but only have the GCXXXXX code. This function will convert the code to a number.

sCode should always include the 2 character prefix - what ever is before the XXXXX 

You don't need to know the mechanics of this conversion but for curiosity I provide the outline anyway:

If the XXXX part is 3 characters or less, just convert using hex
If 4 characters then If code is <= FFFF then use hex conversion else use Base 31 (minus 411120)
if 5 characters or more *always* use base 31 (minus 411120)
The base 31 characters are 0123456789ABCDEFGHJKMNPQRTVWXYZ
(0-9, A-Z minus ILOSU)

To convert the other way use the NumToGsCode() function

Alpha List         Category List

Copyright 2004-2016 CWE Computer Services  
Privacy Policy Contact