MB[script] Scratchpad v0.2
Added by Mr. BS over 11 years ago
I was tired to use inputbox for small code tests, I wanted something with multi-line support. First thing flashed in my mind was the Scratchpad from Mozilla Firefox Dev Tools. Then I made a simple dialog to get the code and run as a regular script, in user point of view it's like an $eval but for whole msl code.
Video demo:¶
<video controls>
<source src="https://www.googledrive.com/host/0B36riaEyLqg_REFmaE1Nc3FtUmM">
</video>
Usage:¶
- /sp <enter>
Changelog¶
- v0.2
- Now it loads previous code on open.
- Added a button to insert fake tab spacing.
- Added an info button to warn about unsupported Alias.
- Remove temp file on unload script.
- Minor improvements. - v0.1
- Initial release
Script:¶
; http://dev.adiirc.com/boards/5/topics/169
; Scratchpad - quick msl code evaluation
; v0.2 by pereba
on *:Unload:.remove scratchpad.txt
menu menubar {
Scratchpad:sp
}
alias sp { if (!$dialog(Scratchpad)) dialog -mp Scratchpad Scratchpad }
dialog Scratchpad {
title "Scratchpad"
size -1 -1 312 220
option dbu
edit "", 1, 0 0 312 198, multi return hsbar vsbar hsbar vsbar
button "Tab", 4, 6 202 28 14
button "Evaluate", 5, 40 202 240 14
button "i", 6, 286 202 20 14
}
alias -l sendkey {
var %name sk $+ $ticks
.comopen %name WScript.Shell
.comclose %name $com(%name,SendKeys,3,bstr,$replacex($1-,{space},$chr(32)))
}
; temp file to store code
alias -l f return scratchpad.txt
; populate box if previous code is found
on *:dialog:Scratchpad:init:*: {
if ($isfile($f)) {
var %i 2, %l $lines($f)
while (%i < %l) {
did -a $dname 1 $read($f,n,%i) $+ $crlf
inc %i
}
}
}
on *:dialog:Scratchpad:*:*: {
if ($devent = sclick) {
; info button
if ($did == 6) {
noop $?!="Remember to not add $chr(160) $chr(160) ALIAS NAME {...} $chr(160) $chr(160) this is not supported."
}
; tab button
if ($did == 4) {
did -f $dname 1 | sendkey {space}{space}
}
; evaluate button
if ($did == 5) {
var %code $did(1).lines
if (%code) {
write -c $f alias sidentifier $chr(123)
var %line = 1
while (%line <= $did(1).lines) {
write -a $f $did(1, %line).text
inc %line
}
write -a $f $chr(125)
.load -rs $f
sidentifier
.unload -rs $f
}
}
}
}
Credits goes to kr0n for the write/load code idea and implementation.
| Scratchpad v0.1.ini (846 Bytes) Scratchpad v0.1.ini | |||
| Scratchpad v0.2.ini (1.66 KB) Scratchpad v0.2.ini |