I've begun. :)
The first search from my VB-code port is a QuickSort routine (qscb)
that sorts the contents of the clipboard and puts it back onto the
clipboard.
Even if you don't think you'd ever use this - look at the code, which
demonstrates how to accomplish clipboard manipulation with js and vbs.
It's pretty slick.
Anyway...
It comes with one option - "/trim" which will trim the spaces from the
ends of every line of the text on the clipboard before it sorts the
values (no, it doesn't put them back ;)).
More code to come.
Regards,
Shawn K. Hall
http://ReliableAnswers.com/
'// ========================================================
"Men are anxious to improve their circumstances, but are
unwilling to improve themselves; they therefore remain
bound."
-- James Allen
<search function="qscb">
<name>VB Script - QuickSort Clipboard</name>
<description>
QuickSorts every line of text on the clipboard and
places it back onto the clipboard.<br />
<div class="helpboxDescLabels">Usage:</div>
<table class="helpboxDescTable">
<tr><td>qscb <strong>[/trim]</strong></td></tr>
</table>
<div class="helpboxDescLabels">Switches:</div>
<table class="helpboxDescTable">
<tr><td>/trim</td><td> - </td><td>Trim each line before sort</td></tr>
</table>
<div class="helpboxDescLabels">Example:</div>
<table class="helpboxDescTable">
<tr><td>qscb</td></tr>
<tr><td>qscb /trim</td></tr>
</table>
</description>
<category>Computers<category>Programming</category></category>
<link>http://www.ReliableAnswers.com/</link>
<contributor>Shawn K. Hall</contributor>
<form name="qscbf"
action="http://reliableanswers.com/x/"
method="post">
<input type="hidden" name="q" value="" />
<textarea name="vbscode" style="display: none;"><![CDATA[
Dim q
q = document.qscbf.q.value
If LCase( q ) = "/trim" Then
Call QuickSortClipboard( True )
Else
Call QuickSortClipboard( False )
End If
Sub QuickSortClipboard( bTrim )
Dim a, lIter
a = Split( ClipBoardGetText, vbCrLf )
If bTrim Then
For lIter = LBound( a ) To UBound( a )
a(lIter) = Trim( a(lIter) )
Next
End If
Call QuickSortA( a, LBound( a ), UBound( a ) )
Call ClipBoardSetText( Join(a, vbCrLf) )
Erase a
End Sub
Sub QuickSortA( ByRef Values, ByVal Min, ByVal Max )
Dim sMed, sMedL, lHi, lLo, lIter
If Min >= Max Then Exit Sub
lIter = Min + Int( Rnd( Max - Min + 1 ) )
sMed = Values( lIter )
sMedL = LCase( Values( lIter ) )
Values( lIter ) = Values( Min )
lLo = Min
lHi = Max
Do
Do While LCase( Values( lHi ) ) >= sMedL
lHi = lHi - 1
If lHi <= lLo Then Exit Do
Loop
If lHi <= lLo Then
Values( lLo ) = sMed
Exit Do
End If
Values( lLo ) = Values( lHi )
lLo = lLo + 1
Do While LCase( Values( lLo ) ) < sMedL
lLo = lLo + 1
If lLo >= lHi Then Exit Do
Loop
If lLo >= lHi Then
lLo = lHi
Values( lHi ) = sMed
Exit Do
End If
Values( lHi ) = Values( lLo )
Loop
Call QuickSortA ( Values, Min, lLo - 1 )
Call QuickSortA ( Values, lLo + 1, Max )
End Sub
Function ClipBoardSetText( sText )
ClipBoardSetText = window.clipboardData.SetData( "Text", sText )
End Function
Function ClipBoardGetText()
ClipBoardGetText = window.clipboardData.GetData( "Text" )
End Function
]]></textarea>
</form>
<script><![CDATA[
function qscb (q)
{
document.qscbf.q.value = q;
//get the vbs code
var qscbt = "";
qscbt = document.qscbf.vbscode.value;
//remove CDATA prefix and trailer
qscbt = qscbt.replace( /(\<\!\[CDATA\[)/g, '' ).replace( /(\]\]\>)/g, '' );
//trim it
qscbt = qscbt.replace(/^\s+/g, '' ).replace(/\s+$/g, '' );
//run the script
window.execScript( qscbt, "vbscript" );
//return
return ( true );
}
]]></script>
<copyright>
Copyright (c) 2002 David Bau
Distributed under the terms of the
GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
</copyright>
</search>