Jump to content


Photo

Age-remover 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:22 AM

I had to manually type in the [-Hyphen] code here, but you need to insert the [-Hyphen] code via the macro commands. For whatever reason, hyphens are not always a [-Hyphen] in my documents but sometimes the - [HyphenCharacter]

^ = whatever your preferred placeholder is.


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

OnNotFound(NoMoreMatches)

PosDocTop ()
SearchString (StrgToLookFor: "[-Hyphen]year[-Hyphen]old")
ReplaceString (RplcStrg: "^[-Hyphen]year[-Hyphen]old")
ReplaceForward (SearchMode: Regular!)
PosDocTop ()
SearchString (StrgToLookFor: "-year-old")
ReplaceString (RplcStrg: "^[-Hyphen]year[-Hyphen]old")
ReplaceForward (SearchMode: Regular!)
PosDocTop ()
vCount:=0
While (True)
SearchString (StrgToLookFor: "^")
SearchNext (SearchMode: Regular!)
PosCharPrevious ()
PosCharPrevious ()
DeleteCharNext ()
DeleteCharNext ()
PosWordNext ()
vCount:=vCount+1 //After any operation you want counted (assuming the processing occurs inside a loop)
EndWhile

Label (NoMoreMatches)

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

Messagebox(;"Finished"; vCount+" ages were removed.") //At the end of the macro (outside the processing loop) you can use a message to display the total count



I received help from WPUniverse in this thread :eclipsee_Victoria:

//Application (WordPerfect; "WordPerfect"; Default!; "EN")
//Removes the ages in a document
QuickmarkSet ()

PosDocTop ()
SearchString (StrgToLookFor: "[-Hyphen]year[-Hyphen]old")
ReplaceString (RplcStrg: "^[-Hyphen]year[-Hyphen]old")
ReplaceForward (SearchMode: Regular!)
PosDocTop ()
SearchString (StrgToLookFor: "-year-old")
ReplaceString (RplcStrg: "^[-Hyphen]year[-Hyphen]old")
ReplaceForward (SearchMode: Regular!)
PosDocTop ()
vCount = 0
OnNotFound(NoMoreMatches)
SearchString (StrgToLookFor: "^")
MatchPositionBefore
While (True)
SearchNext (Regular!)
While(StrIsChar(?LeftChar;;;AlphaNumeric!) = False) //lemoto says this way it doesn't matter if the age is one digit or two
PosCharPrevious
EndWhile
While(StrIsChar(?LeftChar;;;AlphaNumeric!) = True)
DeleteCharPrevious
EndWhile
PosWordNext ()
vCount:=vCount+1
EndWhile

Label (NoMoreMatches)
Messagebox(;"Success!"; vCount+" ages were removed.")
MatchSelection
Return
QuickmarkFind() // Return to the original place in the doc
BookmarkDelete("QuickMark") // Remove the temporary Quickmark

Edited by suzanneMI, 06 July 2008 - 06:40 PM.

  • 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.