[code]
Dim EOL As String = chr(13)
Dim sa() As String = split(clipboard, EOL)
For i As Integer = 0 To UBound(sa)
sa(i) = replaceall(sa(i), chr(34), chr(34) + chr(34))
sa(i) = chr(34) + sa(i) + chr(34)
Next
Dim s As String = join(sa, " + _ " + endofline)
seltext = s[/code]
Will insert whatever is on your clipboard directly into the current code editor with quotes doubled and each line quoted and separated by + _.
[quote=396101:@Lars Lehmann]I find IDE scripts very unhandy, since you always have to load it from external.
Having such a small converter open in a tab of my browser (which is also always open), is for me a better way.[/quote]
Just put them in the Scripts folder next to the IDE or your project and they’ll appear in the File > IDE Scripts menu.
It turns out I have a script like this, just didn’t remember. Written a long time ago, apparently, so forgive any deficiencies.
const kWrapWidth = 80
Function PosOfLastNonWordChar(s As String, endPos As Integer) As Integer
dim pos as integer = endPos
dim unicodeChars as string = "_"
dim chars() as string = s.Split("")
for i as integer = endPos DownTo 1
dim char as string = chars(i - 1)
if char >= "A" and char <= "Z" then
// Keep going
elseif char >= "0" and char <= "9" then
// Keep going
elseif unicodeChars.InStr(char) <> 0 then
// Keep going
else
pos = i
exit
end if
next i
return pos
End Function
dim s as string = SelText
if s = "" then
print "Select some text first."
return
end if
const kQuote = """"
dim addOpenQuote as boolean
dim addCloseQuote as boolean
if s.Left(1) = kQuote then
s = s.Left(2)
addOpenQuote = true
end if
if s.Right(1) = kQuote then
s = s.Left(s.Len - 1)
addCloseQuote = true
end if
dim stack() as string
while s.Len > kWrapWidth
dim pos as integer = PosOfLastNonWordChar(s, kWrapWidth)
stack.Append s.Left(pos)
s = s.Mid(pos + 1)
wend
stack.Append s
s = join(stack, kQuote + " + _" + EndOfLine + kQuote)
if addOpenQuote then
s = kQuote + s
end if
if addCloseQuote then
s = s + kQuote
end if
SelText = s
if not addCloseQuote then
SelStart = SelStart + 1
end if