Page 1 of 1
Searching the Catalog
Posted: 27 Jan 2016 19:48
by Irwin of Upton
Is there any method that can be used to search for a word in the Catalog?
Mine is getting large and while it is a nifty feature sometimes forget what Category an operation was placed in. The right click menu shows many useful features like Sort but not any mention of how to locate.
Re: Searching the Catalog
Posted: 27 Jan 2016 20:27
by highend
You could convert the catalog.dat from HEX to ASCII, strip all control characters and then search the result

Re: Searching the Catalog
Posted: 27 Jan 2016 20:35
by TheQwerty
You can use a script to display and then filter catalog entries, but I cannot think of a way to trigger or jump to an entry after selecting one:
Code: Select all
"Filter Catalog"
$catalog = CatalogReport("C:{Caption}", "I:{Caption}");
$category = '';
$list = '';
foreach($line, $catalog, <crlf>) {
$type = GetToken($line, 1, ':', 't');
$caption = GetToken($line, 2, ':', 't', 2);
if ($type == 'C') {
$category = $caption;
} else {
$list = $list . "$category > $caption<crlf>";
}
}
InputSelect('Your Catalog...', $list, <crlf>, 4+64);
Re: Searching the Catalog
Posted: 27 Jan 2016 21:19
by Irwin of Upton
Thank you, thank you Mr. Qwerty! The script you so generously took the time to code does the job. It is like having a GPS device for the Catalog. Once run the magnifying glass is given the desired destination and then knowing its location "driving there" is easy.
An ingenious solution.
Re: Searching the Catalog
Posted: 27 Jan 2016 21:37
by highend
This slightly modified version removes some imho unnecessary clutter (mainly the display of icon information when there is a "valid" caption)...
Code: Select all
$catalog = CatalogReport("C:{Caption}", "I:{Caption}");
$category = '';
$list = '';
$captionCnt = 1;
foreach($line, $catalog, <crlf>) {
$type = GetToken($line, 1, ':', 't');
$caption = GetToken($line, 2, ':', 't', 2);
if (gettoken($caption, 1, "|")) {
$caption = regexreplace($caption, "\|.*");
}
if ($type == 'C') {
if ($captionCnt == 1) {
$list = $list . recase($caption, "u") . "...<crlf>";
} else {
$list = $list . <crlf> . recase($caption, "u") . "...<crlf>";
}
$captionCnt++;
} else {
$list = $list . " $caption<crlf>";
}
}
InputSelect('Your Catalog...', $list, <crlf>, 4+64);
Re: Searching the Catalog
Posted: 27 Jan 2016 22:02
by TheQwerty
@highend: nice! This might be slightly cleaner code:
Code: Select all
"Filter Catalog"
$catalog = CatalogReport("C:{Caption}...", " {Caption}");
$category = '';
$list = '';
foreach($line, $catalog, <crlf>) {
if ($line Like 'C:*') {
$line = SubStr(Recase($line, 'u'), 2);
if ($list != '') { $list = $list . <crlf>; }
} else {
$line = GetToken($line, 1, '|');
}
$list = $list . $line . <crlf>;
}
InputSelect('Your Catalog...', $list, <crlf>, 4+64);
EDIT: Really unfortunate that the regexreplace cannot convert case so we could remove the loop.

/edit
Caused me to play a bit, I preferred keeping it similar to
List All Commands but inserting a separator between categories:
Code: Select all
"Filter Catalog"
$catalog = CatalogReport("C:{Caption}", " | {Caption}");
$category = '';
$list = '';
foreach($line, $catalog, <crlf>) {
if ($line Like 'C:*') {
$category = SubStr($line, 2);
if ($list != '') {
$list = $list . StrRepeat('-', 80) . <crlf>;
}
} else {
$list = $list . $category . GetToken($line, 2, '|',, 1) . <crlf>;
}
}
InputSelect('Your Catalog...', $list, <crlf>, 4+64);
Re: Searching the Catalog
Posted: 27 Jan 2016 22:07
by highend
Really unfortunate that the regexreplace cannot convert case so we could remove the loop.
Yeah, we really need an inbuild better regex engine than the ancient vbscript.dll one...
I modified my code 2-3 times (to make it look a bit nicer (and to reimplement the display of the second (icon) part of the caption if the first part is empty)
It's a curse that the moderator edits aren't displayed, isn't it

Re: Searching the Catalog
Posted: 27 Jan 2016 22:16
by TheQwerty
highend wrote:It's a curse that the moderator edits aren't displayed, isn't it

Nope, not at all. In fact, that's my favorite feature of the forum!

Re: Searching the Catalog
Posted: 27 Jan 2016 22:28
by highend
Nope, not at all. In fact, that's my favorite feature of the forum!
Pssssssst, I've just edited your post! *eg*
Re: Searching the Catalog
Posted: 28 Jan 2016 15:05
by kunkel321
You two are a hoot!