GSAK (Geocaching Swiss Army Knife)
Contents - Index

Eval (function)

Eval(sData) : String

Use this function to evaluate and convert the value of any special tag(s) to a string variable, when variable substitution is off. The function returns the converted special tag(s), but you can also include string literals. For example if the current waypoint has the code of "GCABCD" and smart name of "BigRed", then:

Vsub Status=off
$data = Eval("%smart") 
# $data is now equal to "BigRed".

$data = eval("The code is %code")
# $data is now equal to "The code is GCABCD"

Using eval() with variable substitution turned off, will also ensure you don't get a syntax error if the data contains " (double quotes). For example, if the cache name was - My "little cache"

Then the following code would cause a syntax error in the macro because of the extra double quotes when the special tag is resolved:

$data = "%name"

To make sure you don't get a syntax error when using special tags this way you would need to use the following code:

Vsub status=off
$data = eval("%name")
vsub status=on

Of course the following code would give you the same result:

$data = $d_name

However, there are times when you need to expand special tags in this way (when using a form input for example) 

Note: This function supersedes the GetSpecial command and is much quicker. 

Alpha List         Category List

Copyright 2004-2016 CWE Computer Services  
Privacy Policy Contact