GSAK (Geocaching Swiss Army Knife)
 

Contents - Index


SaveFilter (function)

SaveFilter() : string

This function will save all your current filter settings to a variable that can later be used by the RestoreFilter function. Only information saved to a variable by this function can be used in the RestoreFilter function otherwise you will get an error. You would normally save your current filter settings to a variable just by running the following command:
 

$SavedFilter = SaveFilter()


You can then use the $SavedFilter variable at any time later in the macro in the RestoreFilter command to regenerate the filter settings (and run it). To fully understand this function also study the RestoreFilter function.

This function has no parameters, but is a function because it returns a string variable. 

Note: SaveFilter() does not support joined filters (the filter could be the result of many join operations). You can test to see if the current filter is the result of a join or not by using the SysInfo() function. 

There is a way to effectively restore *any* filter, joined or not. However, this method has a subtle, but significant difference in the end result. This difference needs to be understood and evaluated to dertermine if it is a viable work around/solution for your intended use and audiance.

That is, you can take a snap shot of the "codes" in the current filter. When your macro code has finished its work, you can then create a filter of those "codes".

The difference now is that your filter criteria is now basically a "static" one, that just matches those codes.

Below is sample code that shows how this can be done:

# Save the codes in our current filter to a sqldatabase in memory
$status = dbtosqlite("caches","code",":memory:")
 
# cancel the current filter to work on the whole database
cancelfilter
msgok msg="Filter now cancelled"


# You would now execute your main macro code here
GoSub Name=DoSomething

# Now we need to restore our filter of codes

# First get our list of saved codes via sql
$codes = sqlite("sql","select * from caches")

# Housekeeping - close our in memory Sqlite database as no longer needed
$status = sqlite("close","")

# clear out all macro flags
macroflag type=clear range=all

# Now match these codes and set the macroflag
$number = codematch($codes,$_NewLine,"M")

# Now set a filter of our matched codes by filtering on macroflag
Mfilter expression=$d_Macroflag

BeginSub Name=DoSomething
# macro code here
EndSub


Related: RestoreFilter()

Alpha List         Category List

Copyright 2004-2011 CWE Computer Services  
Privacy Policy Contact