PChange

Replaces the first occurrence of the specified text, searching the selected range, the active story, or all stories of the current publication. Leaves the new text selected.


Command constructor

PChange(const char * sFindWhat, const char * sChangeTo, short cSearchRange, PMBool bWrapAround, PMBool bMatchCase, PMBool bWholeWord, PMBool bClearAttr);
const char * sFindWhat;
Text to search for.
const char * sChangeTo;
Replacement text.
short cSearchRange;
kFCSSelectedText to search selected text
kFCSCurrentStory to search current story only, starting from position of insertion point (default setting)
kFCSAllStories to search all stories in current publication, starting from beginning of currently active story
kParmDefault to use default or previously defined range
kParmDontCare to let system choose range based on current text selection. If text is selected, the PChange command searches only selected text; if no text is selected, it searches only the current story, starting from position of insertion point.
PMBool bWrapAround;
false to stop searching when PageMaker reaches end of story
true to continue searching from beginning of story when PageMaker reaches end of story (default setting)
PMBool bMatchCase;
true to turn off case-sensitive searching (default setting)
true to turn on case-sensitive searching (to match capitalization of search text exactly)
PMBool bWholeWord;
false to search for any occurrence of specified text (default setting), even if text is found within another word (for example, searching for "story" could yield "history," as well as "story")
true to search for specified text as a whole word only, disregarding occurrences where text is embedded within another word.
PMBool bClearAttr;
false to use existing text and paragraph attributes (default setting)
true to clear all attribute settings (both Find and Change settings).
Story editor only. The PChange command works only in story editor. Use the PEditStory command to invoke the story editor.

Current publication only. Unlike the Change dialog box, the PChange command cannot search multiple publications. It can search only the stories in the currently active publication.

Change next. The PChange command locates and changes only one instance of the search text. You must repeat the command, or better yet, use the PChangeNext command, to find and change the next occurrence of the search text. Use the PChangeAll command to find and change all occurrences of the search text.

bWrapAround. PageMaker disregards the bWrapAround parameter in two cases, when cSearchRange is set to either:

Optional parameters. PageMaker requires only the sFindWhat and sChangeTo parameters. If you do not include values for the other parameters, PageMaker uses the settings of the most recently executed PFind, PChange, or PChangeAll command. (If none of these commands has been executed this session, PageMaker uses the default settings noted in the parameter list above.) If you change the cSearchRange using the PFind, PChange, or PChangeAll commands, PageMaker resets the starting position of the search.

Setting text and paragraph attributes. To search for and replace text and paragraph attributes (e.g., font, type size, paragraph style), use the PFindTypeAttr1, PFindTypeAttr2, PFindParaAttr, PChangeTypeAttr1, PChangeTypeAttr2, and PChangeParaAttr commands, followed by the PChange command with bClearAttr set to false.

Changing only text attributes. To change text attributes only (e.g., all 10 -point, bold text to 9-point, Helvetica bold), use the PFindTypeAttr1, PFindTypeAttr2, PChangeTypeAttr1, and PChangeTypeAttr2 commands to set the desired attributes. (Be sure to clear the paragraph attributes with the PFindParaAttr and PChangeParaAttr commands.) Then, using the PChange command, specify an empty string for both sFindWhat and sChangeTo and set bClearAttr to useattributes or 0. For example, to change all 10-point, bold text in a publication to 9-point, Helvetica bold, the commands are:

PFindTypeAttr2(-3, -3, "Any", -3);   // to clear the other type attributes
PChangeTypeAttr2(-3, -3, "Any", -3); // to clear the other type attributes
PFindParaAttr("Any", -3, -3);        // to clear the paragraph attributes
PChangeParaAttr("Any", -3, -3);      // to clear the paragraph attributes
PFindTypeAttr1("Any", 10, -3, kStyleBold, -3, -3);
PChangeTypeAttr1("Helvetica", 9, -3, kStyleBold, -3, -3);
PChange("", "", kFCSAllStories, false, false, false, false);

Searching for and changing special characters. You enter a special character as part of your search or replacement text using the same key combinations that you type directly in the Change dialog box. Refer to Adobe PageMaker 6.5 Help > Shortcuts > Special Characters.

Scripts palette. Do not use the PChange command in scripts you plan to run using the Scripts palette. When PageMaker finds no match or completes the search, the Scripts palette interprets this as an error and stops at that point in the script.

Exceptions. There are two common situations which will result in an exception being thrown by the constructor:

Example. The following example selects a story, inserts the insertion point into the story, and switches to story editor. It then searches the current story for the word "rumba," regardless of the capitalization or attribute settings. The search begins at the position of the insertion point and wraps to the be ginning of the story, if necessary. It replaces the first match it finds with the word "cha-cha" and leaves the changed text selected.

PSelect(1); // select story
PTextEdit();
// insert insertion point into beginning of selected story
PEditStory();
// switch to story editor
PChangeAll("rumba", "cha-cha", kFCSCurrentStory, kFCAnyCase, kFCWholeWord, kFCClear);


See also

The PChangeAll, PChangeParaAttr, PChangeTypeAttr1, PChangeTypeAttr2, PChangeWindow, PFind, PFindNext, PFindParaAttr, PFindTypeAttr1, PFindTypeAttr2, and PFindWindow commands

The PGetChangeParaAttr, PGetChangeTypeAttr1, PGetChangeTypeAttr2, PGetChangeWindow, PGetFindParaAttr, PGetFindTypeAttr1, PGetFindTypeAttr2, and PGetFindWindow queries

Adobe PageMaker 6.5 Help > Commands > Utilities > Change

Adobe PageMaker 6.5 Help > Shortcuts > Special Characters


Copyright © 1996, Adobe Systems Incorporated. All rights reserved.

Comments or suggestions? Contact Adobe Developer Support