Hello all,

This search allows you to execute VBS code inline. You can optionally
have it return the results to the clipboard or the DQSD window. You
can use "VB Shorthand Notation" to return the results to the DQSD
window, as you would the debug window by prefixing it with a question
mark (?). Here are a couple functional examples:

  vbs ?Replace("This ugly text", "ugly ", "")

  vbs ClipBoardSetText UCase(ClipBoardGetText())

This one is pretty neat, as not only does it demonstrate how to make
vbscript code work, it also has a function library, included within a
textarea in the search, that it appends to your executing code to
provide you with an extensible model for adding additional methods to
the code, extending it for your own habits and needs.

Regards,

Shawn K. Hall
http://ReliableAnswers.com/

'// ========================================================
   "Red meat is NOT bad for you.
    Now blue-green meat, THAT'S bad for you!"
      -- Tommy Smothers
<search function="vbs">
  <name>VB Script</name>
  <description>
    Performs Visual Basic Script code interpretation.<br />
    <div class="helpboxDescLabels">Usage:</div>
    <table class="helpboxDescTable">
      <tr><td>vbs <em>[?]vb-script</em></td></tr>
    </table>
    <div class="helpboxDescLabels">Switches:</div>
    <table class="helpboxDescTable">
      <tr><td>?</td><td> - </td><td>Return value is to appear in DQSD, like the Debug Window of Visual Basic</td></tr>
    </table>
    <div class="helpboxDescLabels">Supporting Functions:</div>
    <table class="helpboxDescTable">
      <tr><td nowrap="nowrap"> ClipBoardSetText( sText ) </td><td> Places sText, a text value, onto the clipboard </td></tr>
      <tr><td> ClipBoardGetText() </td><td> Obtains the clipboard text data </td></tr>
      <tr><td> - </td><td> ...add more by editing vbs.xml to include additional functions within the vbscode &lt;textarea&gt; </td></tr>
    </table>
    <div class="helpboxDescLabels">Example:</div>
    <table class="helpboxDescTable">
      <tr><td>vbs msgbox("hi")</td></tr>
      <tr><td>vbs ?Replace("This ugly text", "ugly ", "")</td></tr>
      <tr><td>vbs ClipBoardSetText Replace(ClipBoardGetText, vbCrLf, " ")</td></tr>
      <tr><td>vbs ClipBoardSetText UCase(ClipBoardGetText)</td></tr>
    </table>
  </description>
  <category>Computers<category>Programming</category></category>
  <link>http://www.ReliableAnswers.com/</link>
  <contributor>Shawn K. Hall</contributor>
  
  <form name="vbsf"
    action="http://reliableanswers.com/x/";
    method="post">
    <input type="hidden" name="qs" value="" />
    <textarea name="vbscode" style="display: none;"><![CDATA[

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 vbs (q)
  {
  //set debug mode
    var qs = q;
    if (qs.charAt(0) == "?"){
      qs = "document.deff.q.value = " + qs.substring(1, qs.length);
    }

  //get the vbs code
    var vbst = "";
    vbst = document.vbsf.vbscode.value;
  //remove CDATA prefix and trailer
    vbst = vbst.replace( /(\<\!\[CDATA\[)/g, '' ).replace( /(\]\]\>)/g, '' );
  //trim it
    vbst = vbst.replace(/^\s+/g, '' ).replace(/\s+$/g, '' );

  //append functions
    qs = qs + "\n" + vbst;

  //execute code
    window.execScript (qs, "vbscript");
    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>

Reply via email to