user:skript:category
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:skript:category [2010/11/03 19:19] – medwyn_cz | user:skript:category [2021/05/02 19:02] (current) – [Stažení] mikrom | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Category ====== | ====== Category ====== | ||
- | FIXME /* Stručný popis funkce skriptu. Prvních cca 140 znaků popisu se zobrazuje | + | Knihovna, která umožňuje autorům skriptů generovat výstupy z GeoGetu řazené a seskupované dle přidělených klíčů - kategorií. |
+ | Ve výchozím nastavení jsou data exportována | ||
===== Autor ===== | ===== Autor ===== | ||
- | * **[[http:// | + | * **[[http:// |
- | * **[[http:// | + | * **[[http:// |
===== Automatická instalace ===== | ===== Automatická instalace ===== | ||
Line 16: | Line 17: | ||
==== Dostupné funkce ==== | ==== Dostupné funkce ==== | ||
+ | * Seřazeny tak, jak budou pravděpodobně při používání volány | ||
+ | |||
+ | <code delphi> | ||
+ | * Initializes the library | ||
+ | | ||
+ | <code delphi> | ||
+ | * Set the callback procedure. This procedure is called back during the execution of CatSort procedure. | ||
+ | * The parameter supplied must be a link to a procedure signed: <code delphi> | ||
+ | |||
<code delphi> | <code delphi> | ||
* Starts new transaction | * Starts new transaction | ||
- | |||
- | <code delphi> | ||
- | * Commits the transaction | ||
<code delphi> | <code delphi> | ||
Line 40: | Line 47: | ||
* Returns count of points in given category | * Returns count of points in given category | ||
- | <code delphi> | + | <code delphi> |
+ | * Commits the transaction | ||
+ | |||
+ | <code delphi> | ||
* Frees up the category database. | * Frees up the category database. | ||
- | /* ==== Ukázka | + | ==== Ukázkové exportní makro ==== |
- | Pokud je to možné a vhodné, měl by popis obsahovat | + | |
+ | Zde je plný opis zdrojového kódu makra, které používá tuto knihovnu ke generování HTML výstupu seřazeného dle kategorie keší. Výstup je jinak shodný s makrem **html.gge.pas**. | ||
+ | |||
+ | <code delphi html-sorted.gge.pas> | ||
+ | {$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: | ||
+ | begin | ||
+ | result := ' | ||
+ | end; | ||
+ | |||
+ | {This function returns the description of this export format} | ||
+ | function ExportDescription: | ||
+ | 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: | ||
+ | begin | ||
+ | //Only divide points in to categories, do not generate any output yet! | ||
+ | |||
+ | CatAddGC(GC, | ||
+ | |||
+ | Result := ''; | ||
+ | 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 := ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | for n := 0 to geo.Waypoints.Count | ||
+ | if geo.Waypoints[n].IsListed then | ||
+ | begin | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | Result := Result + ' | ||
+ | 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 | ||
+ | | ||
+ | | ||
+ | end; | ||
+ | GeoBusyProgress(exportCounter, | ||
+ | |||
+ | //Handle the point export | ||
+ | exportData := exportData + GenerateOutputGeo(geo); | ||
+ | end | ||
+ | else if wpt <> nil | ||
+ | then ShowMessage(' | ||
+ | else ShowMessage(' | ||
+ | end; | ||
+ | |||
+ | procedure ExportInit; | ||
+ | begin | ||
+ | CatInit; // | ||
+ | CatSetCallback(@ExportCallback); | ||
+ | CatBeginUpdate; | ||
+ | |||
+ | exportData := ''; | ||
+ | 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: | ||
+ | begin | ||
+ | ExportInit(); | ||
+ | |||
+ | Result := '< | ||
+ | Result := Result + '< | ||
+ | Result := Result + '< | ||
+ | Result := Result + '< | ||
+ | Result := Result + '</ | ||
+ | Result := Result + '< | ||
+ | Result := Result + '< | ||
+ | end; | ||
+ | |||
+ | {This function returns the data which should be written to the end of the exported file} | ||
+ | function ExportFooter: | ||
+ | begin | ||
+ | CatEndUpdate; | ||
+ | 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 + '</ | ||
+ | end; | ||
+ | |||
+ | {This function is called after the output is written to the file} | ||
+ | function ExportAfter(value: | ||
+ | begin | ||
+ | Result := ''; | ||
+ | RunShell(value); | ||
+ | end; | ||
+ | </code> | ||
/* ===== Instalace ===== | /* ===== Instalace ===== | ||
Line 54: | Line 193: | ||
/* ===== Poznámky, známé problémy ===== | /* ===== Poznámky, známé problémy ===== | ||
Případné poznámky ke skriptu - např. další plán vývoje, známé chyby apod. */ | Případné poznámky ke skriptu - např. další plán vývoje, známé chyby apod. */ | ||
+ | |||
+ | ===== Seznam skriptů, které používají tuto knihovnu ===== | ||
+ | {{topic> | ||
+ | |||
+ | Pokud jste narazili na skript, který knihovnu používá, ale není zde uveden, kontaktujte, | ||
===== Stažení ===== | ===== Stažení ===== | ||
- | <box round 95% #DEE7EC> | + | <WRAP round download> |
- | :!: Stáhnout aktuální verzi: ~~DOWNLOAD category-*.gip highest~~ | + | Stáhnout aktuální verzi: ~~DOWNLOAD category-*.gip highest~~ |
- | </box> | + | </WRAP> |
==== Seznam dostupných verzí ==== | ==== Seznam dostupných verzí ==== | ||
Line 64: | Line 208: | ||
===== Seznam změn ===== | ===== Seznam změn ===== | ||
- | === 0.1.1 (2010/11/03) === | + | === 0.1.3 (2011/01/04) === |
- | | + | |
+ | | ||
<hidden onHidden=": | <hidden onHidden=": | ||
- | === 0.1 (2010/ | + | === 0.1.2 (2010/ |
- | | + | |
+ | |||
+ | === 0.1.1 (2010/ | ||
+ | * Changed from unit to includable source | ||
</ | </ | ||
- | {{tag> | + | {{tag>author_geby author_medwyn |
user/skript/category.1288808369.txt.gz · Last modified: 2010/11/03 00:00 (external edit)