Basic quote script, excluding the fact that it filters out quotes containing selected text.
-Update v1.1: Updated .Quote. It can now search for a for a quote containing , without having to use the param
on *:START: { If (!$exists(XCeptQuotes.txt)) { write XCeptQuotes.txt } | set %xc.version v1.1 | hlp }
menu channel {
Quotes
.Open/Close Dialog://If ($dialog(Quotes)) { .timer 1 .1 /dialog -x Quotes Quotes } | //If (!$dialog(Quotes)) { .timer 1 .1 /dialog -m Quotes Quotes }
.Show Commands:/hlp
}
alias hlp {
echo -a 3.9:15 -------------------------------
echo -a 3.9:15 .Quote <N> <text>
echo -a 3.9:15 With no params, reads random quote.
echo -a 3.9:15 With just N param, reads # quote.
echo -a 3.9:15 With just the <text> param, searches for the first quotes containing wildcard <text>
echo -a 3.9:15 With both params, searches quote file for Nth matching wildcard of <text>
echo -a 3.9:15 .AddQuote <text>
echo -a 3.9:15 Adds quote to database.
echo -a 3.9:15 -------------------------------
}
dialog Quotes {
title XCept Quotes %xc.version
size -1 -1 165 84
option dbu
button "Add Quote", 2, 132 1 33 18, multi
button "Delete Quote", 3, 132 19 33 18, multi
button "Search Quotes", 4, 132 37 33 18, multi
button "Refresh", 5, 0 55 33 18, multi
button "Filter Quotes", 6, 33 55 33 18, multi
button "Import Quotes", 7, 66 55 33 18, multi
button "Clear all Quotes", 8, 99 55 33 18, multi
button "Exit", 9, 132 55 33 18, multi
list 1, -1 0 133 55, size vsbar
edit "", 10, 0 74 165 10, read autohs autovs
}
on *:DIALOG:Quotes:init:0: {
If ($fopen(quote)) { .fclose quote }
.fopen quote XCeptQuotes.txt
While (!$feof) {
didtok Quotes 1 C $fread(quote)
}
.fclose quote
}
on *:DIALOG:Quotes:dclick:1: { msg $active $did(1).seltext }
on *:DIALOG:Quotes:sclick:1: { did -ra Quotes 10 $did(1).seltext }
on *:DIALOG:Quotes:sclick:2: {
set %add.q $strip($input(Add Quote:,edqau,XCept Quotes %xc.version,<Insert Quote Here>),bruc)
If (!%add.q) || ($read(XCeptQuotes.txt,w,* $+ %add.q $+ *)) { unset %add.q | halt }
write XCeptQuotes.txt %add.q
did -a Quotes 1 $strip(%add.q,bruc)
unset %add.q
}
on *:DIALOG:quotes:sclick:3: {
If (!$did(1).seltext) { halt }
If ($fopen(q)) { .fclose q }
.fopen q XCeptQuotes.txt
var %i 1
While (!$feof) {
If ($fread(q) = $did(1).seltext) { write -dl $+ %i XCeptQuotes.txt | did -d Quotes 1 $didwm(Quotes,1,$did(1).seltext) }
inc %i
}
.fclose q
}
on *:DIALOG:quotes:sclick:4: {
set %search.q $input(Search for quote containing text:,edqau,XCept Quotes %xc.version,<Insert Text Here>)
If (!%search.q) { halt }
did -r Quotes 1
set %found none
var %i 1
While ($read(XCeptQuotes.txt,w,* $+ %search.q $+ *,%i)) {
didtok Quotes 1 C $read(XCeptQuotes.txt,pnw,* $+ %search.q $+ *,%i)
set %i $calc($readn + 1)
set %found yes
}
If (%found = none) {
didtok Quotes 1 C Found no Quotes for " $+ %search.q $+ "
}
If (%found = yes) {
did -i Quotes 1 1 ----
did -i Quotes 1 1 Searching for Results for " $+ %search.q $+ "...
}
unset %found %search.q %i
}
on *:DIALOG:Quotes:sclick:5: { resetquotes }
on *:DIALOG:Quotes:sclick:6: {
did -r Quotes 1
set %search.q $input(Filter out all quotes containing text:,edqau,XCept Quotes %xc.version,<Insert Text Here>)
var %i 1
While ($read(XCeptQuotes.txt,%i)) {
If (%search.q isin $read(XCeptQuotes.txt,%i)) { inc %i | continue }
didtok Quotes 1 C $read(XCeptQuotes.txt,%i)
inc %i
}
did -i Quotes 1 1 ----
did -i Quotes 1 1 Filtering out all Quotes containing text " $+ %search.q $+ "...
unset %i %t %search.q
}
on *:DIALOG:Quotes:sclick:7: {
set %Y/N $input(Load quotes from Clipboard?,auqvyd,XCept Quotes %xc.version)
If (%Y/N = $no) { unset %Y/N | goto one }
If (%Y/N = $yes) { unset %Y/N | goto two }
:one
set %Y/N $input(Load quotes from a Text File?,auqvyd,XCept Quotes %xc.version)
If (%Y/N = $no) { unset %Y/N | halt }
If (%Y/N = $yes) { unset %Y/N | goto three }
:two
var %i 1
While ($cb(%i)) {
write -i XCeptQuotes.txt $cb(%i)
didtok Quotes 1 C $cb(%i)
inc %i
}
unset %i
halt
:three
set %Y/N $sfile($iif(%lastdir,%lastdir,$mircdir),Select a file to import text from. XCept Quotes %xc.version,Import)
set %lastdir $nofile(%Y/N)
var %i 1
While ($read(%Y/N,%i)) {
write -i XCeptQuotes.txt $read(%Y/N,%i)
did -a Quotes $read(%Y/N,%i)
inc %i
}
unset %i %Y/N
}
on *:DIALOG:Quotes:sclick:8: {
set %Y/N $input(Are you sure you want to clear your quotes list? You cannot retrieve it.,auwvyd,XCept Quotes %xc.version)
If (%Y/N = $no) { unset %Y/N | halt }
If (%Y/N = $yes) {
unset %Y/N
.remove XCeptQuotes.txt
write XCeptQutoes.txt
}
}
on *:DIALOG:Quotes:sclick:9: { dialog -x Quotes Quotes }
on *:INPUT:*: {
If (!$ctrlenter) {
If ($1 = .Quote) {
If ($3-) {
haltdef
If ($fopen(q)) { .fclose q }
.fopen q XCeptQuotes.txt
var %i 1
While (!$feof) && (!$ferr) {
If ($read(XCeptQuotes.txt,w,* $+ $3- $+ *,$2) = $fread(q)) { set %q %i }
inc %i
}
.fclose q
If (%q) {
msg $active 3,1.9:15Selected Quote [# $+ %q $+ ]9:3.
msg $active $read(XCeptQuotes.txt,w,* $+ $3- $+ *,$2)
unset %q
}
}
If (!$3-) && ($2) {
If ($2 isnum) && ($2 < $lines(XCeptQuotes.txt)) {
haltdef
msg $active 3,1.9:15Selected Quote [# $+ $2 $+ ]9:3.
msg $active $read(XCeptQuotes.txt,$2)
}
If ($2 !isnum) {
haltdef
msg $active 3,1.9:15Searched Quote " $+ $2 $+ "9:3.
msg $active $read(XCeptQuotes.txt,w,* $+ $2 $+ *)
}
}
If (!$2) {
haltdef
set %rand $rand(1,$lines(XCeptQuotes.txt))
msg $active 3,1.9:15Random Quote [# $+ %rand $+ ]9:3.
msg $active $read(XCeptQuotes.txt,%rand)
unset %rand
}
}
If ($1 = .AddQuote) {
If ($2-) {
haltdef
write -i XCeptQuotes.txt $2-
If ($dialog(Quotes)) { did -a Quotes 1 $2- }
msg $active 3,1.9:15Added Quote.9:3
}
}
}
}
alias resetquotes {
did -r Quotes 1
If ($fopen(quote)) { .fclose quote }
.fopen quote XCeptQuotes.txt
While (!$feof) {
didtok Quotes 1 C $fread(quote)
}
.fclose quote
}