##################### traditionals ####################
#
# find all stuff in recent PQs and is findable
#

%saveset name=gui:tomtomexports

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-trad-diff:size=Micro,suffix=micro,diff=%{diff},dogctodiff=%[dogctodiff,0,text=Replace GC prefix with difficulty/terrain,type=checkbox],dosolved=%[dosolved,1,text=Replace Puzzle coordinates with solved coordinates,type=checkbox]
%endforeach


%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-trad-diff:size=Small,suffix=small,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-trad-diff:size=Regular,suffix=regular,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-trad-diff:size=Large,suffix=large,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

#
# find everything not found above (eg size not set)
#
%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%search
set:gui:tomtomexports
  # only traditionals
  &&cache:subtype==Traditional Cache
  # exclude finds
  &&(attr:found=-||attr:found==0)
  # get all other sizes
  &&cache:groundspeak_container<>Micro
  &&cache:groundspeak_container<>Regular
  &&cache:groundspeak_container<>Large
  &&cache:groundspeak_container<>Small

%include devices/tomtom-modifiers

%export
system:cmd=gpsbabel -i geo -f %{file:loc} -o tomtom -F geocaches-nosize-%{diff}.ov2

%endforeach

##################### by type ####################
#
# find all stuff in recent PQs and is findable
#
%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-bytype-diff:type=Virtual Cache,suffix=virtual,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-bytype-diff:type=Multi-cache,suffix=multi,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-bytype-diff:type=Webcam Cache,suffix=webcam,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-bytype-diff:type=Event Cache,suffix=event,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach

%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%script
devices/tomtom-bytype-diff:type=Earth Cache,suffix=earth,diff=%{diff},dogctodiff=%[dogctodiff],dosolved=%[dosolved]
%endforeach


#################### Unknown Types ####################
%search
## do a catch all
set:gui:tomtomexports
  # only the right type
  &&cache:subtype<=>Virtual Cache
  &&cache:subtype<=>Multi-cache
  &&cache:subtype<=>Webcam Cache
  &&cache:subtype<=>Traditional Cache
  &&cache:subtype<=>Event Cache
  &&cache:subtype<=>Earth Cache
  # include Unknowns, which are handled below.
  &&cache:subtype<=>Unknown Cache
  # exclude finds
  &&(attr:found=-||attr:found==0)

%include devices/tomtom-modifiers

%export
system:cmd=gpsbabel -i geo -f %{file:loc} -o tomtom -F geocaches-unknowntype.ov2


################ Puzzles #################################
# then do IN-FIELD marked unknowns
#
%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%search
set:gui:tomtomexports
  # solvable in the field
  &&attr:infield=1
  # with difficulty matching the current iterator
  &&cache:difficulty==%{diff}
  # only unknowns
  &&cache:subtype==Unknown Cache
  # exclude finds
  &&(attr:found=-||attr:found==0)

%include devices/tomtom-modifiers

%export
system:cmd=gpsbabel -i geo -f %{file:loc} -o tomtom -F geocaches-unknown-%{diff}.ov2
%endforeach

#################################################
# then do SOLVED unknowns
#
%foreach diff 1 1.5 2 2.5 3 3.5 4 4.5 5
%search
set:gui:tomtomexports
  # solved
  &&attr:puzn>0
  # with difficulty matching the current iterator
  &&cache:difficulty==%{diff}
  # only unknowns
  &&cache:subtype==Unknown Cache
  # exclude finds
  &&(attr:found=-||attr:found==0)

%include devices/tomtom-modifiers

%export
system:cmd=gpsbabel -i geo -f %{file:loc} -o tomtom -F geocaches-solved-%{diff}.ov2
%endforeach

# XXX
######################################################################
# all extra waypoints in the EXTRA WAYPOINTS set
#%search
#(set:import:% [set1]:waypoints||
# set:import:% [set2]:waypoints||
# set:import:% [set3]:waypoints||
# set:import:% [set4]:waypoints)
#
#%export
#mem:palm-extra-points
#
#%display
#count:Extra Waypoints       :
