Findreplace functions

 < Day Day Up > 

Find/replace functions

Find/replace functions handle find and replace operations. They cover basic functionality, such as finding the next instance of a search pattern, and complex replacement operations that require no user interaction.

dreamweaver.findNext()

Availability

Dreamweaver 3; modified in Dreamweaver MX 2004.

Description

Finds the next instance of the search string that was specified previously by dreamweaver.setUpFind(), by dreamweaver.setUpComplexFind(), or by the user in the Find dialog box, and selects the instance in the document.

Arguments

 {bUseLastSetupSearch} 

  • The bUseLastSetupSearch argument, which is optional, is a Boolean value. If bUseLastSetupSearch is the value true, which is the default if no argument is given, the function does a find-next operation using the parameters specified by a previous call to either the dreamweaver.setupComplexFind() function or the dreamweaver.setupComplexFindReplace() function. If you set bUseLastSetupSearch to the value false, the function ignores the previously set up search and performs a search for the next instance of the text that is currently selected in the document.

Returns

Nothing.

Enabler

See "dreamweaver.canFindNext()" on page 1071.

dreamweaver.replace()

Availability

Dreamweaver 3.

Description

Verifies that the current selection matches the search criteria that was specified by dreamweaver.setUpFindReplace(), by dreamweaver.setUpComplexFindReplace(), or by the user in the Replace dialog box; the function then replaces the selection with the replacement text that is specified by the search request.

Arguments

None.

Returns

Nothing.

dreamweaver.replaceAll()

Availability

Dreamweaver 3.

Description

Replaces each section of the current document that matches the search criteria that was specified by dreamweaver.setUpFindReplace(), by dreamweaver.setUpComplexFindReplace(), or by the user in the Replace dialog box, with the specified replacement content.

Arguments

None.

Returns

Nothing.

dreamweaver.setUpComplexFind()

Availability

Dreamweaver 3.

Description

Prepares for an advanced text or tag search by loading the specified XML query.

Arguments

 xmlQueryString 

  • The xmlQueryString argument is a string of XML code that begins with dwquery and ends with /dwquery. (To get a string of the proper format, set up the query in the Find dialog box, click the Save Query button, open the query file in a text editor, and copy everything from the opening of the dwquery tag to the closing of the /dwquery tag.)

Returns

Nothing.

Example

The first line of the following example sets up a tag search and specifies that the scope of the search should be the current document. The second line performs the search operation.

dreamweaver.setUpComplexFind('<dwquery><queryparams matchcase="false" ignorewhitespace="true" useregexp="false"/><find> <qtag qname="a"><qattribute qname="href" qcompare="="qvalue="#"> </qattribute><qattribute qname="onMouseOut" qcompare="=" qvalue="" qnegate="true"></qattribute></qtag></find></dwquery>');dw.findNext();

dreamweaver.setUpComplexFindReplace()

Availability

Dreamweaver 3.

Description

Prepares for an advanced text or tag search by loading the specified XML query.

Arguments

 xmlQueryString 

  • The xmlQueryString argument is a string of XML code that begins with the dwquery tag and ends with the /dwquery tag. (To get a string of the proper format, set up the query in the Find dialog box, click the Save Query button, open the query file in a text editor, and copy everything from the beginning of the dwquery tag to the end of the /dwquery tag.)

Returns

Nothing.

Example

The first statement in the following example sets up a tag search and specifies that the scope of the search should be four files. The second statement performs the search and replace operation.

dreamweaver.setUpComplexFindReplace('<dwquery><queryparams matchcase="false" ignorewhitespace="true" useregexp="false"/><find><qtag qname="a"><qattribute qname="href" qcompare="=" qvalue="#"></qattribute><qattribute qname="onMouseOut" qcompare="=" qvalue="" qnegate="true"></qattribute></qtag> </find><replace action="setAttribute" param1="onMouseOut" param2="this.style.color='#000000';this.style.fontWeight='normal'"/>< /dwquery>'); dw.replaceAll();

dreamweaver.setUpFind()

Availability

Dreamweaver 3.

Description

Prepares for a text or HTML source search by defining the search parameters for a subsequent dreamweaver.findNext() operation.

Arguments

 searchObject 

The searchObject argument is an object for which the following properties can be defined:

  • The searchString is the text for which to search.

  • The searchSource property is a Boolean value that indicates whether to search the HTML source.

  • The {matchCase} property, which is optional, is a Boolean value that indicates whether the search is case-sensitive. If this property is not explicitly set, it defaults to false.

  • The {ignoreWhitespace} property, which is optional, is a Boolean value that indicates whether white space differences should be ignored. The ignoreWhitespace property defaults to false if the value of the useRegularExpressions property is true, and true if the useRegularExpressions property is false.

  • The {useRegularExpressions} property is a Boolean value that indicates whether the searchString property uses regular expressions. If this property is not explicitly set, it defaults to a value of false.

Returns

Nothing.

Example

The following code demonstrates three ways to create a searchObject object:

 var searchParams; searchParams.searchString = 'bgcolor="#FFCCFF"'; searchParams.searchSource = true; dreamweaver.setUpFind(searchParams); var searchParams = {searchString: 'bgcolor="#FFCCFF"', searchSource: true}; dreamweaver.setUpFind(searchParams); dreamweaver.setUpFind({searchString: 'bgcolor="#FFCCFF"', searchSource: true}); 

dreamweaver.setUpFindReplace()

Availability

Dreamweaver 3.

Description

Prepares for a text or HTML source search by defining the search parameters and the scope for a subsequent dreamweaver.replace() or dreamweaver.replaceAll() operation.

Arguments

 searchObject 

The searchObject argument is an object for which the following properties can be defined:

  • The searchString property is the text for which to search.

  • The replaceString property is the text with which to replace the selection.

  • The searchSource property is a Boolean value that indicates whether to search the HTML source.

  • The {matchCase} property, which is optional, is a Boolean value that indicates whether the search is case-sensitive. If this property is not explicitly set, it defaults to a false value.

  • The {ignoreWhitespace} property, which is optional, is a Boolean value that indicates whether white space differences should be ignored. The ignoreWhitespace property defaults to false if the useRegularExpressions property has a value of TRue, and defaults to a value of TRue if the useRegularExpressions property has a value of false.

  • The {useRegularExpressions} property is a Boolean value that indicates whether the searchString property uses regular expressions. If this property is not explicitly set, it defaults to a value of false.

Returns

Nothing.

Example

The following code demonstrates three ways to create a searchObject object:

var searchParams; searchParams.searchString = 'bgcolor="#FFCCFF"'; searchParams.replaceString = 'bgcolor="#CCFFCC"'; searchParams.searchSource = true; dreamweaver.setUpFindReplace(searchParams); var searchParams = {searchString: 'bgcolor="#FFCCFF"', replaceString: bgcolor="#CCFFCC"', searchSource: true}; dreamweaver.setUpFindReplace(searchParams); dreamweaver.setUpFindReplace({searchString: 'bgcolor="#FFCCFF"', replaceString: 'bgcolor="#CCFFCC"', searchSource: true});

dreamweaver.showFindDialog()

Availability

Dreamweaver 3.

Description

Opens the Find dialog box.

Arguments

None.

Returns

Nothing.

Enabler

See "dreamweaver.canShowFindDialog()" on page 1077.

dreamweaver.showFindReplaceDialog()

Availability

Dreamweaver 3.

Description

Opens the Replace dialog box.

Arguments

None.

Returns

Nothing.

Enabler

See "dreamweaver.canShowFindDialog()" on page 1077.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net