Code: Select all
; 640,sz
;///////////////////////////////////////////////////
;
; Size converter IDE external tool
;
; Usage: Compile this code and install as an IDE
; external tool with keyboard shortcut
; activation. (I used CTRL-P)
;
; Place a commented line at the top of your
; source in this format: ; size,var
;
; Example top line: ; 640,sz
;
; select numbers or groups of numbers from
; your code and hit your shortcut
;
; 320,55,19,420 gets instantly changed to:
;
; 0.5000*sz,0.0859*sz,0.0297*sz,0.6563*sz
;
; I actually used the tool for this demo,
; note the comment in the first line
;
; Spaces will get trimmed out, so just modify
; this code if you don't want that.
;
;///////////////////////////////////////////////////
*size = AllocateMemory(34)
HandleIDESci = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
SendMessage_(HandleIDESci, #WM_GETTEXT, 32, *size)
a$ = PeekS(*size)
a$ = Left(a$, FindString(a$, #CR$)-1)
a$ = RemoveString(a$, ";")
a$ = RemoveString(a$," ")
size$ = StringField(a$, 1, ",")
var$ = StringField(a$, 2, ",")
a.d = ValD(size$)
SendMessage_(HandleIDESci, #WM_COPY,0,0)
b$ = GetClipboardText()
j=CountString(b$,",")
For i = 1 To j+1
num.d = ValD(Trim(StringField(b$,i,",")))
num$+StrD(num/a,4)+"*"+var$ :If i<j+1:num$+",":EndIf
Next
SetClipboardText(num$)
SendMessage_(HandleIDESci, #WM_PASTE,0,0)