Jump to content


Photo

He/She or She/He replacement macro


Old topic!
Guest, the last post of this topic is over 365 days. Only Star PT contributors are allowed to post to posts this old.


  • This topic is locked This topic is locked
No replies to this topic

#1 suzanneMI

suzanneMI

    Junior Member

  • Members
  • 16 posts

Posted 06 July 2008 - 10:12 AM

While learning how to get counts for actions performed, I received some assistance at WPUniverse in this thread. Here is my macro for male-to-female search and replace. Simply reverse the information for a female-to-male scenario, rename and save.

Application (WordPerfect; "WordPerfect"; Default!; "EN")
QuickmarkSet () // Temporary Quickmark

vCount:=0
PosPageTop()

SearchCaseSensitive (Yes!)
search[] = {
" male ";
" He ";
" His ";
" he ";
" his ";
" gentleman ";
" man "
}

ReplaceWithCase (Yes!)
replace[] = {
" female ";
" She ";
" Her ";
" she ";
" her ";
" lady ";
" woman "
}

If(search[0] <> replace[0])
MessageBox(;"Error"; "Search and Replace arrays do not match - macro quits")
Return
EndIf

Declare changed[search[0]]

OnNotfound(alldone)
ForNext(i; 1; search[0]; 1)
PosDocTop
changed[i] = 0
While(True)
SearchString (search[i])
ReplaceString (replace[i])
SearchNext
ReplaceCurrent
changed[i] = changed[i] + 1
vCount := vCount + 1
EndWhile
alldone:
EndFor

QuickmarkFind() // Return to the original place in the doc
BookmarkDelete("QuickMark") // Remove the temporary Quickmark

Display(On!)
vMsg = ""
ForNext(i; 1; search[0]; 1)
vMsg = vMsg + search[i] + " was replaced " + changed[i] + " time/s" + NtoC(HRt!)
EndFor
vMsg = vMsg + NtoC(HRt!) + " A total of " + vCount+ " replaces performed in this document."
Messagebox(;"Finished";vMsg)

Return

  • 0

716


Old topic!
Guest, the last post of this topic is over 365 days. Only Star PT contributors are allowed to post to posts this old.