{$include category.lib.pas} //Include the library var exportData : String; //this field holds the exported data var exportCounter : Integer; //this field holds the current number of already exported points var lastCategory : String; //this field holds the name of the last exported category {This function returns the extension of the exported file} function ExportExtension: string; begin result := 'HTML'; end; {This function returns the description of this export format} function ExportDescription: string; begin result := 'HTML list - sorted by category'; end; {This function returns the data about one point, which should be written to the body of the export file} function ExportPoint: string; begin //Only divide points in to categories, do not generate any output yet! CatAddGC(GC,GC.CacheType); //Register the processed point to the category library. Use the cachetype as the category Result := ''; //We are using category library as a workaround. No data must be exported to the file at this stage. end; {This function generates the HTML output based on the given TGeo} function GenerateOutputGeo(geo :TGeo): string; var n: integer; wcnt: integer; begin wcnt := 0; for n := 0 to geo.Waypoints.Count - 1 do if geo.Waypoints[n].IsListed then inc(wcnt); Result := ' ' + CRLF; Result := Result + ' ' + geo.ID + '' + CRLF; Result := Result + ' ' + geo.IDtag + '' + CRLF; Result := Result + ' ' + '' + geo.Name + '' + CRLF; Result := Result + ' ' + ansitoutf(geo.GetCoord) + '' + CRLF; Result := Result + ' ' + CRLF; Result := Result + ' ' + CRLF; Result := Result + ' Hint: ' + geo.hint + '' + CRLF; Result := Result + ' ' + CRLF; for n := 0 to geo.Waypoints.Count - 1 do if geo.Waypoints[n].IsListed then begin Result := Result + ' ' + CRLF; Result := Result + ' ' + geo.Waypoints[n].TypeID + ' ' + geo.Waypoints[n].prefixid+ '' + CRLF; Result := Result + ' ' + geo.Waypoints[n].Name + '' + CRLF; Result := Result + ' ' + ansitoutf(geo.Waypoints[n].GetCoord) + '' + CRLF; Result := Result + ' ' + CRLF; Result := Result + ' ' + CRLF; Result := Result + ' ' + geo.Waypoints[n].Description + '' + CRLF; Result := Result + ' ' + CRLF; end; end; {This function will be called by the category library and will take care of the export itself} procedure ExportCallback(const geo: tgeo; const wpt: TWpt; category: string); begin if geo <> nil then begin exportCounter := exportCounter + 1; //Increment the counter //handle busy dialog if lastCategory <> category then begin lastCategory := category; GeoBusyKind('Generating HTML output - (' + category + ', ' + IntToStr(CatCategorySize(category))+ ' points)'); end; GeoBusyProgress(exportCounter,CatSize); //Handle the point export exportData := exportData + GenerateOutputGeo(geo); end else if wpt <> nil then ShowMessage('Error occured. No waypoints should be added to category library in this demo export!') //Handle the waypoint export else ShowMessage('Error occured. Invalid parameters supplied!'); end; procedure ExportInit; begin CatInit; //Initialize the category library CatSetCallback(@ExportCallback); //Set the callback procedure. This procedure will be called by the category library during the sort process CatBeginUpdate; //Start transaction on category library exportData := ''; //Make sure that the result variable is empty at the beginning exportCounter := 0; //Set the number of already exported points to 0 end; {This function returns the data which should be written to the beginning of the exported file} function ExportHeader: string; begin ExportInit(); //Initialize the export Result := '' + CRLF; Result := Result + '' + CRLF; Result := Result + 'GeoGet cache list' + CRLF; Result := Result + '' + CRLF; Result := Result + '' + CRLF; Result := Result + '' + CRLF; Result := Result + '' + CRLF; end; {This function returns the data which should be written to the end of the exported file} function ExportFooter: string; begin CatEndUpdate; //Close transaction on category library CatSort; //Call the main function of the library. This call will ensure that exportData variable will be full of sorted output CatFinish; //Free the memory used by the category library Result := exportData; //Write the exported data to the file Result := Result + '
' + CRLF + '' + CRLF; //close the file end; {This function is called after the output is written to the file} function ExportAfter(value: string): string; begin Result := ''; RunShell(value); //Open the result file in the browser end;