#******************************************* # MacVersion = 1.1 # MacDescription = 50 State Challenge # MacAuthor = brdad # MacFileName = 50StateChallenge.gsk # MacUrl =http://www.geocachingmaine.org/forum/attachment.php?attachmentid=505&d=1277341592 #******************************************* SQLSort OrderBy=Distance $i = 1 $Output = "" #Check if we're using Miles or Kilometres IF SysInfo("Distance") = "K" $distunits = "km" ELSE $distunits = "miles" ENDIF IF $distunits="" $msg = "Sorry, something is wrong, I couldn't read your Distance setting" CANCEL MSG=$msg ENDIF $States = "Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|" $States = $States + "Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|" $States = $States + "Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|" $States = $States + "Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming" While $i <= 50 $State = Extract($States, "|", $i) $StateExp = "\b" + $State + "\b" SHOWSTATUS Msg=$i of 50 - $State # set a filter on all caches that are in Maine and match the current state name. MFILTER Where=g_regex($StateExp,name) and State ='Maine' $Output = $Output + "" + $State + "
" + $_NewLine If $_FilterCount >0 SQLSort OrderBy=Distance Goto Position=Top While Not($_Eol) If $d_found = True $Output = $Output + " " Else $Output = $Output + "     " EndIf BEGINCASE CASE $d_Archived = True $htmlleft = "" $htmlright = "" CASE $d_TempDisabled = True $htmlleft = "" $htmlright = "" OtherWise $htmlleft = "" $htmlright = "" ENDCASE $Output = $Output + NumToStr($d_distance) + " " + $distunits + " - " + $htmlleft + $d_Name + $htmlright + " ($d_Code) by $d_PlacedBy
" Goto Position=Next EndWhile Else $Output = $Output + "No caches match this criteria.
" EndIf $Output = $Output + "
" + $_NewLine $i = $i + 1 EndWhile # Create the base file $HTMLFile=$_Install + "\Macros\50StateChallenge.html" # HTML Header $HTMLOut = "" + $_NewLine $HTMLOut = $HTMLOut + "" + $_NewLine $HTMLOut = $HTMLOut + "" + $_NewLine $HTMLOut = $HTMLOut + "" + $_NewLine $HTMLOut = $HTMLOut + "" + $_NewLine $HTMLOut = $HTMLOut + $Output SHOWSTATUS MSG=Saving HTML ... # Write the data to the file $Error = PutFile($HTMLFile,$HTMLOut) IF Left($Error,7) = "*Error*" PAUSE Msg="$Error" CANCEL ENDIF CancelFilter FILEOPEN File="$HTMLFile" wait=yes