A while back Christopher Bradford created a script to toggle table
borders on and off.

I modded that script to allow for quick and easy changes to the OUTPUT
attributes of CFCOMPONENT and CFFUNCTION.

If you assign this script to a toolbar button in CF Studio or Homesite,
you can quickly toggle the ability to display output in your CFCs.

Here's the script.  Save the code as ToggleOutput.js (or an appropriate
name) and point to it from Studio's/Homesite's toolbar.

Enjoy!


/*      This script created by Christopher Bradford, Alive! Online
Design.
    You may distribute it freely, but please keep the headers intact.

    This is just a regular expression search and replace, but it works
nicely.    
*/

// these are constant for the message boxes
var hsYesNoCancelQuestion = 35;
var hsOKInfo = 64;

// these are constants for button values when clicked
var hsCancel = 2;
var hsYes = 6;
var hsNo = 7;

function Main () {

var app = Application;

    if (app.ActiveDocument.SelLength > 0) {
    
            // figure out the scope of the search
    var intUseSelText = app.MessageBox("Restrict replace to selected
text?","Regular Expression Search and Replace",hsYesNoCancelQuestion);

    if (intUseSelText == hsYes) { strText = app.ActiveDocument.SelText;
}         // use selected text
    else if (intUseSelText == hsNo) {strText = app.ActiveDocument.Text;
}        // use whole document
    else { strText = ""; }  // they canceled the operation
         }
    else { strText = app.ActiveDocument.Text; }

if (strText != "") {                  // if this is empty, it means they
cancelled, so the script ends

var intOffOn = app.MessageBox("Do you want to allow output for
CFCOMPONENT and CFFUNCTION?","CFCOMPONENT and CFFUNCTION output
toggle",hsYesNoCancelQuestion);

if (intOffOn != hsCancel) {
if (intOffOn == hsYes)
        {
        var re = /([<cffunction]|[<cfcomponent]
[^>]*)(output="?)No("?[^>]*>)/gi;
        var strNew = strText.replace(re,"$1$2Yes$3");
        eval ("app.ActiveDocument." + ((intUseSelText == hsYes) ?
"SelText" : "Text") + " = strNew");    // replace the right text
(selected text or full text)
        }
else if (intOffOn = hsNo)
        {    
        var re = /([<cffunction]|[<cfcomponent]
[^>]*)(output="?)Yes("?[^>]*>)/gi;
        var strNew = strText.replace(re,"$1$2No$3");
        eval ("app.ActiveDocument." + ((intUseSelText == hsYes) ?
"SelText" : "Text") + " = strNew");    // replace the right text
(selected text or full text)
        }


}

}

app.MessageBox("Done!","Successful",hsOKInfo);

}
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to