SMF Script 8 — File Browser
SMFScript8v8.13 / SMFScript8v8.13 / system / textpad.mrc
textpad.mrc — 3 KB — Download this file
alias textpad if ($dialog(tp) = $null) dialog -mn tp tp | did -h tp 7
dialog tp {
size -1 -1 359 300
title "TextPad v1.0"
edit "",2,64 5 290 290,multi,autovs,vsbar,hsbar,return
edit "",7,5 212 54 23,read
button "New",6,5 6 54 26
button "Open",1,5 37 54 26
button "Import",5,5 68 54 26
button "Save",3,5 109 54 26
button "Save As..",4,5 140 54 26
button "Close",8,5 181 54 26,cancel
}
on *:dialog:tp:sclick:*: if ($did = 6) { did -r tp 2 | unset %tp.file | dialog -t tp TextPad v1.0 } | if ($did = 1) .timer 1 0 tp.opn | if ($did = 5) .timer 1 0 tp.imprt | if ($did = 3) .timer 1 0 tp.save | if ($did = 4) .timer 1 0 tp.save.as | if ($did = 8) unset %tp.file
alias tp.save.as if (%tp.dir) set %tp.file $$dir="Save File As.." %tp.dir | else set %tp.file $$dir="Save File As.." | if ($chr(32) isin %tp.file) set %tp.file " $+ %tp.file $+ " | if ($lof(%tp.file)) .remove %tp.file | set %tp.lines $did(tp,2).lines | :loop | inc %tp.lines.inc | if (%tp.lines.inc <= $did(tp,2).lines) { set %tp.lines.cnt $did(tp,2,%tp.lines.inc) | if (%tp.lines.cnt) write %tp.file %tp.lines.cnt | else write %tp.file $chr(32) | goto loop } | dialog -t tp TextPad - $remove($nopath(%tp.file),") | unset %tp.line* | set %tp.dir $remove($nofile(%tp.file),")
alias tp.save if (%tp.file = $null) && (%tp.dir) set %tp.file $$dir="Save File As.." %tp.dir | if (%tp.file = $null) && (%tp.dir = $null) set %tp.file $$dir="Save File As.." | if ($chr(32) isin %tp.file) set %tp.file " $+ %tp.file $+ " | if ($lof(%tp.file)) .remove %tp.file | set %tp.lines $did(tp,2).lines | :loop | inc %tp.lines.inc | if (%tp.lines.inc <= $did(tp,2).lines) { set %tp.lines.cnt $did(tp,2,%tp.lines.inc) | if (%tp.lines.cnt) write %tp.file %tp.lines.cnt | else write %tp.file $chr(32) | goto loop } | dialog -t tp TextPad - $remove($nopath(%tp.file),") | unset %tp.line* | set %tp.dir $remove($nofile(%tp.file),")
alias tp.imprt if (%tp.dir) set -u0 %tp.lines.imprt $$dir="Import File" %tp.dir | else set -u0 %tp.lines.imprt $$dir="Import File" | if ($chr(32) isin %tp.lines.imprt) set -u0 %tp.lines.imprt " $+ %tp.lines.imprt $+ " | loadbuf -o tp 2 %tp.lines.imprt | set %tp.dir $remove($nofile(%tp.lines.imprt),")
alias tp.opn if (%tp.dir) set %tp.file $$dir="Open File" %tp.dir | else set %tp.file $$dir="Open File" | did -r tp 2 | if ($lof(%tp.file) > 23000) tp.err Textpad can't open files larger than 23000 bytes. | if ($right(%tp.file,4) != .txt) && ($right(%tp.file,4) != .dat) && ($right(%tp.file,4) != .ini) tp.err Textpad only opens .txt .dat or .ini files.@Please consider using "import" instead. | if ($chr(32) isin %tp.file) set %tp.file " $+ %tp.file $+ " | loadbuf -o tp 2 %tp.file | dialog -t tp TextPad - $remove($nopath(%tp.file),") | set %tp.dir $remove($nofile(%tp.file),") | :end
alias tp.err dialog -mn err err | did -a err 2 $gettok($1-,1,64) | if ($gettok($1-,2,64)) did -a err 3 $gettok($1-,2,64) | halt
dialog err {
title "Error!"
size -1 -1 243 86
button "OK",1,94 55 54 26,ok
text "",2,5 5 233 13,center
text "",3,5 22 233 13,center
}