Project

General

Profile

[script] Scratchpad v0.2 » Scratchpad v0.2.ini

Mr. BS, 11/02/2015 04:31 AM

 
; 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
}
}
}
}
(2-2/2)